Recent

Author Topic: How to vacuum a SQLite database via SQLDB?  (Read 2768 times)

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
How to vacuum a SQLite database via SQLDB?
« on: January 17, 2018, 12:02:28 am »
How can I vacuum a SQLite database and receive the results of that operation via SQLDB?

Thanks in advance for all pointers!
Lazarus 2.0.4/FPC 3.0.4/Win 64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: How to vacuum a SQLite database via SQLDB?
« Reply #2 on: January 17, 2018, 05:46:23 pm »
Not quite - I knew how to run vacuum already - I am interested in also receiving a result of that operation. Just snooped around at the SQLite site and I may have to live without such results - as you can see below it seems to be a void function :(

/*
** The non-standard VACUUM command is used to clean up the database,
** collapse free space, etc.  It is modelled after the VACUUM command
** in PostgreSQL.
**
** In version 1.0.x of SQLite, the VACUUM command would call
** gdbm_reorganize() on all the database tables.  But beginning
** with 2.0.0, SQLite no longer uses GDBM so this command has
** become a no-op.
*/
void sqlite3Vacuum(Parse *pParse){
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v ){
    sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);
  }
  return;
}
Lazarus 2.0.4/FPC 3.0.4/Win 64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to vacuum a SQLite database via SQLDB?
« Reply #3 on: January 17, 2018, 07:34:05 pm »
Not quite - I knew how to run vacuum already - I am interested in also receiving a result of that operation.
you can run
PRAGMA page_count;
PRAGMA page_size;

before and after the vacuum to show the changes if any or find some other pragma that returns some stats. If everything else fails there is the PRAGMA stats, which is not to be used outside of testing/developing environment and therefore not recommended to be used in any end user application, but if you only show the information as before and after vacuum that might not be that problematic.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018