Overview
Comment:Only apply journal_mode if necessary, this gains about 4-5 ms on every page!
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: c84ca4b90a9643169a7eb15800b6bd609a9d4647e935265e54ceab7358a15f4a
User & Date: bohwaz on 2022-10-26 02:12:31
Other Links: branch diff | manifest | tags
Context
2022-10-26
02:32
Don't store user and permissions in session, request the database directly check-in: 5c93319f45 user: bohwaz tags: dev
02:12
Only apply journal_mode if necessary, this gains about 4-5 ms on every page! check-in: c84ca4b90a user: bohwaz tags: dev
01:49
Fix typo check-in: c39e1a8885 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/DB.php from [cf2da7e9fc] to [0ab3ecee7f].

209
210
211
212
213
214
215



216
217
218
219

220
221
222
223
224
225
226

        // Activer les contraintes des foreign keys
        $this->db->exec('PRAGMA foreign_keys = ON;');

        // 10 secondes
        $this->db->busyTimeout(10 * 1000);




        // Performance enhancement
        // see https://www.cs.utexas.edu/~jaya/slides/apsys17-sqlite-slides.pdf
        // https://ericdraken.com/sqlite-performance-testing/
        $this->exec(sprintf('PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA journal_size_limit = %d;', 32 * 1024 * 1024));


        self::registerCustomFunctions($this->db);
    }

    static public function registerCustomFunctions($db)
    {
        $db->createFunction('dirname', [Utils::class, 'dirname']);







>
>
>
|
|
|
|
>







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230

        // Activer les contraintes des foreign keys
        $this->db->exec('PRAGMA foreign_keys = ON;');

        // 10 secondes
        $this->db->busyTimeout(10 * 1000);

        $mode = $this->db->querySingle('PRAGMA journal_mode;');

        if (strtoupper($mode) != 'WAL') {
            // Performance enhancement
            // see https://www.cs.utexas.edu/~jaya/slides/apsys17-sqlite-slides.pdf
            // https://ericdraken.com/sqlite-performance-testing/
            $this->exec(sprintf('PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA journal_size_limit = %d;', 32 * 1024 * 1024));
        }

        self::registerCustomFunctions($this->db);
    }

    static public function registerCustomFunctions($db)
    {
        $db->createFunction('dirname', [Utils::class, 'dirname']);