Small. Fast. Reliable.
Choose any three.

This information is obsolete. You are looking at the CVSTrac source management system display for SQLite that was replaced by Fossil on 2009-08-11. The information shown here has not been updated since that cut-over. These pages are retained for historical reference only.

Page History

Turn Off History

The SQLite homepage boasts that the size of the library is less than 250KiB. But some people report library sizes over twice that big. Is the homepage wrong?

No. The size of the object code depends on what compiler optimizations are used. Generally speaking, there is a tradeoff between size and performance. The more memory you devote to a program the faster it will run.

The following table shows the object-code size of a pre-3.3.14 version of SQLite versus the run-time for the "speed1.test" performance test in the source tree.

GCC Options Size (KiB) Size (relative) Runtime (relative)
none 362 1.62 1.17
-O0 407 1.82 1.72
-O1 293 1.31 1.15
-Os 224 1.00 1.19
-O2 306 1.37 1.09
-O3 513 2.29 1.00
As you can see, the size of the library ranges from 224 KiB up to 513 KiB depending on what compiler optimizations are used. The range is performance is not as drastic. But the smallest version of the library is still almost 20% slower than the fastest version. Note that the precompiled binaries available for download from the SQLite website are compiled with -O2 which gives a good balance between size and performance.

So, Yes, SQLite really does weight in at less than 250KiB when compiled with -Os. But if you want to add that extra 20% performance boost of -O3, you'll need to allow the library to more than double in size.

Test Information

The above tests were run on a SuSE 10.1 system with GCC 4.1.0 using the amalgamation source file "sqlite3.c". The "-fomit-frame-pointer" option was used in every cases except the first "none" case. Other compile-time options where:

  • -DHAVE_FDATASYNC=1
  • -DHAVE_GMTIME_R=1
  • -DHAVE_LOCALTIME_R=1
  • -DHAVE_USLEEP=1
  • -DSQLITE_ENABLE_REDEF_IO=1

Other Compilers

Readers are invited to run similar size versus speed studies on other compilers and operating systems and report their findings below