Skip to content

Commit

Permalink
Move sql optimizations to php
Browse files Browse the repository at this point in the history
  • Loading branch information
karlomikus committed Dec 9, 2024
1 parent 8a09e56 commit dbc0b04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kami\Cocktail\Providers;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -24,6 +24,10 @@ public function register()
*/
public function boot()
{
// Model::preventLazyLoading(!app()->isProduction());
DB::statement('
PRAGMA temp_store = memory;
PRAGMA cache_size = -20000;
PRAGMA mmap_size = 2147483648;
');
}
}
3 changes: 3 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', storage_path('bar-assistant/database.ba3.sqlite')),
'prefix' => '',
'journal_mode' => 'wal',
'foreign_key_constraints' => true,
'busy_timeout' => 5000,
'synchronous' => 'NORMAL',
],

'sqlite_import_from_v2' => [
Expand Down
8 changes: 4 additions & 4 deletions resources/docker/dist/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ if [ ! -f "$db_file" ]; then
touch "$db_file"
fi

# Enable WAL mode
echo "[BAR-ASSISTANT] Enabling database WAL mode..."
sqlite3 "$db_file" 'pragma journal_mode=wal;'
sqlite3 "$db_file" 'pragma synchronous=NORMAL;'
# Enable WAL mode, done via php
# echo "[BAR-ASSISTANT] Enabling database WAL mode..."
# sqlite3 "$db_file" 'pragma journal_mode=wal;'
# sqlite3 "$db_file" 'pragma synchronous=NORMAL;'

# Start running artisan commands
cd "$APP_BASE_DIR"
Expand Down

0 comments on commit dbc0b04

Please sign in to comment.