27 comments

[ 1.5 ms ] story [ 84.8 ms ] thread
A nice interview, though from 2007. One thing has changed a smidgeon: "he has a self-imposed limit on the size of his product: 250KB. And he's stuck to both aims". The FAQ on sqlite.org says "With all features enabled, the library size can be less than 500KiB ... If optional features are omitted, the size of the SQLite library can be reduced below 300KiB." Close though!
Also out of date. The 3.10.2 shared library is over 1 MiB on my system.
Compiling with -Os brings it down to 800 KB.

  % gcc -c sqlite3.c
  % ls -l sqlite3.o
  -rw-r--r--  1 dalke  admin  1270372 Feb  6 04:11 sqlite3.o
  % gcc -c sqlite3.c -Os
  % ls -l sqlite3.o
  -rw-r--r--  1 dalke  admin  805044 Feb  6 04:12 sqlite3.o

  % clang -c sqlite3.c
  % ls -l sqlite3.o
  -rw-r--r--  1 dalke  admin  1248704 Feb  6 04:15 sqlite3.o
  % clang -c -Os sqlite3.c
  % ls -l sqlite3.o
  -rw-r--r--  1 dalke  admin  796888 Feb  6 04:16 sqlite3.o
778 KiB is still some 50% larger than 500.
Using "gcc -Os -m32 -c sqlite3.c; size sqlite3.o" I get 443,264 bytes using the latest SQLite source on Ubuntu.

The "size" command gives a more accurate measurement of what actually ends up in a compiled and stripped binary. "ls -l" includes symbolic and linking info that gets stripped from the finished binary.

Thanks for the pointer to 'size'. I so rarely compile code these days. FWIW, on my Mac with 3100200, clang -Os -m32 is 495,508 bytes while gcc is 507,378.
Are you the author of SQLite or did you just name your account so for other reasons?
From their comment history it seems like the GP really is SQLite's author, Richard Hipp. Cool!
Yes, I am.
May I ask you about the current state of sqlite4?
Clang also has -Oz for even more aggressive size optimizations. I find that it is identical codegen to -Os half the time and shows some nice size reductions the other half of the time.
This might have to do with 64 bit platforms. I would test this on a 32 bit binary.
We should have a bonus for finding great old articles that never were posted to HN before.

There was another one earlier today: https://news.ycombinator.com/item?id=11048637.

yeah I'll take a look, @dang the web rusts a lot so a lot of old stuff might be archived [0] there.

[0] Internet Archive https://archive.org/

For the future, HN's software could call the Wayback Machine's "save page now" API on all front-page links.
Definitely willing to do that. Lord knows we do it enough by hand already.
So how many SQLite databases are in use? "We don't have a good way of counting it," he says, "but we're guessing it's the most widely deployed SQL database in the world."

This article came out before the original iPhone was released -- it certainly is by now, probably by an order of magnitude.

Chrome uses it for local storage too right?
And Firefox. There are probably more instances of SQLite in use than humans on the planet.
Just "an order of magnitude"? I suspect you are off by an order of magnitude. If you count each deployed instance of each product using it, it's probably the most popular by close to 10 orders of magnitude.

Edit: phones are just the start. Numerous embedded products use it - the kind that ship in such large quantities that a couple pennies per device become significant sums of money. And even in the phone case, every app is using a separate database.

10 orders of magnitude is a lot. Are you really saying there are ten billion times more SQLlite databases than the next most popular SQL?
That's probably excessive by a lot, but every modern smartphone has at least one sqlite bundled (possibly more, some software will bundle their own in case the system changes its version), OSX bundles it (and Apple Mail uses it for some stuff), Chrome and Firefox bundle it, …
Off by "an (one) order of magnitude", i.e. off by 2 orders of magnitude.
(comment deleted)
what happened to SQLite 4?
This is from 2007.
Hacker news is too often obsessed with get rich quick schemes, and devising new ways to rip people off. It's nice to hear a story about people who just wants to write good, useful software, and release it to the public domain.
> The author disclaims copyright to this source code. In place of a legal notice, here is a blessing: may you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely, never taking more than you give.

Wow! That is the most enlightened disclaimer I've ever read.