Ticket #140 (closed enhancement: fixed)

Opened 10 months ago

Last modified 8 months ago

Add auto_vacuum to SQLite database installs

Reported by: rickc Owned by:
Priority: major Milestone: 0.4.1
Component: Habari Core Software Version: SVN
Keywords: SQLite, has_patch Cc: rickc

Description

SQLite will quickly grow in size as data is added and deleted. Today I ran the VACUUM command on mine. It shrank from 45 megabytes to 52 kilobytes. If the database is created with

PRAGMA auto_vacuum = 1

the will not grow without end because after each commit to the database empty pages are moved to the end of the file and the file is truncated to remove them. The pragma has to be run when the database is created. It has no effect if used after there are tables in the database.

Attachments

sqlite_pragmas.diff (10.4 kB) - added by rickc 9 months ago.
Allow an SQLite installation to run pragmas when the database is created
bug_140.patch (1.3 kB) - added by itrebal 9 months ago.
Modified version of the previous fix; dbdelta now runs insert/update queries

Change History

Changed 9 months ago by itrebal

The SQLite sql_t function supports replacing 'OPTIMIZE TABLE...' to vacuum, but it seems that OPTIMIZE TABLE isn't run very often (ever?) Maybe we should cron-job this.

Rickc, would you write patch for (or at the very least, a new version of) http://trac.habariproject.org/habari/browser/trunk/htdocs/system/schema/sqlite/schema.sql to support it?

Changed 9 months ago by rickc

OPTIMIZE TABLE/VACUUM is only run on a mass delete of spam, so it isn't run very often. I can write a patch.

Changed 9 months ago by itrebal

Rick, I meant in particular to have PRAGMA auto_vacuum = 1 set on each table so it does auto-vacuum.

Changed 9 months ago by rickc

Allow an SQLite installation to run pragmas when the database is created

Changed 9 months ago by rickc

  • keywords SQLite, has_patch added; SQLite removed

The attached patch will allow an SQLite installation to run any pragmas when the database is created. A pragma to enable auto_vacuum is added to the SQLite schema file.

Changed 9 months ago by itrebal

Modified version of the previous fix; dbdelta now runs insert/update queries

Changed 9 months ago by ringmaster

  • status changed from new to closed
  • resolution set to fixed

Applied bug_140.patch in r1396.

Changed 8 months ago by freakerz

  • milestone changed from 0.5 to 0.4.1
Note: See TracTickets for help on using tickets.