Opened 6 years ago
Closed 3 years ago
#3697 closed enhancement (fixed)
sqlite db: automatically enable vacuum
Reported by: | mlennert | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.6.2 |
Component: | Database | Version: | svn-releasebranch76 |
Keywords: | sqlite vacuum | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
I just noticed that a mapset sqlite db file was huge, despite the fact that there was only one small vector file left in it. Running 'vacuum;' in the sqlite database reduced the announced file size from 47G to 78K !
There is a pragma auto_vacuum which allows to enable an auto-vacuum mode, which is not as efficient as calling the vacuum command, as it does not defragment the database, but I would think that it would at least keep file size to expected levels.
I would, therefore, plead for enabling this pragma by default at database creation and setting it to 1 (full). I think this would be the behavior expected by most users.
Attachments (1)
Change History (15)
follow-ups: 2 4 comment:1 by , 6 years ago
by , 6 years ago
Attachment: | sqlite_vacuum_atexit.patch added |
---|
VACUUM sqlite db when GRASS is terminating
comment:2 by , 6 years ago
VACCUMing is a great improvement!
Replying to mmetz:
I would prefer to VACUUM the sqlite db when the GRASS session is terminating, i.e. in lib/init/grass.py. This would not slow down standard db operations and leaves the db in a clean state.
I would like that idea as well to add that during session termination.
Perhaps likewise also for PostgreSQL and mySQL/MariaDB?
comment:3 by , 6 years ago
Kitchen talk: grass.core.start_command() might be even more fun launched upon session termination :-)
follow-up: 6 comment:4 by , 6 years ago
Replying to mmetz:
I would prefer to VACUUM the sqlite db when the GRASS session is terminating, i.e. in lib/init/grass.py. This would not slow down standard db operations and leaves the db in a clean state.
+1
You are absolutely right, of course ;-)
For me this can be committed to trunk. We'll see then if it has any negative consequences.
comment:6 by , 6 years ago
Replying to mlennert:
Replying to mmetz:
I would prefer to VACUUM the sqlite db when the GRASS session is terminating, i.e. in lib/init/grass.py. This would not slow down standard db operations and leaves the db in a clean state.
Added benefit: already existing databases are also cleaned, while with PRAGMA auto_vacuum=1 only newly created databases would be cleaned.
comment:7 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This seems to be solved, so closing.
Thanks, MarkusM !
follow-up: 9 comment:8 by , 6 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I'd like to see this in 7.6 as well... Any objections?
comment:9 by , 6 years ago
Replying to neteler:
I'd like to see this in 7.6 as well... Any objections?
You're right, that would be nice. I don't know if the solution implemented in trunk is transferable as is to 7.6 ?
comment:11 by , 6 years ago
Milestone: | 7.8.0 → 7.6.0 |
---|---|
Version: | unspecified → svn-releasebranch76 |
Should be all backported (see above), pls test.
comment:14 by , 3 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
This was committed to trunk as well as backported to 7.6 release branch at that time, so closing this one as fixed.
Replying to mlennert:
This auto_vacuum would occur at every transaction commit. Maybe it is more efficient to VACUUM the sqlite db now and then, e.g. when the database is closed or when the GRASS session is terminated.
VACUUM when the database is closed would still be quite often, e.g. with every SELECT statement or also just describing the table.
I would prefer to VACUUM the sqlite db when the GRASS session is terminating, i.e. in lib/init/grass.py. This would not slow down standard db operations and leaves the db in a clean state.