News for hackers. Stuff that matters.
Re:Why is C faster than Java: git vs JGit by erichocean on Thursday January 12, 2012 @06:01PM (#3458363)
See: http://www.sqlite.org/different.html

Money quote about half-way down the page: "SQL statements compile into virtual machine code"

Every SQL database engine compiles each SQL statement into some kind of internal data structure which is then used to carry out the work of the statement. But in most SQL engines that internal data structure is a complex web of interlinked structures and objects. In SQLite, the compiled form of statements is a short program in a machine-language like representation. Users of the database can view this virtual machine language by prepending the EXPLAIN keyword to a query.

The use of a virtual machine in SQLite has been a great benefit to the library's development. The virtual machine provides a crisp, well-defined junction between the front-end of SQLite (the part that parses SQL statements and generates virtual machine code) and the back-end (the part that executes the virtual machine code and computes a result.) The virtual machine allows the developers to see clearly and in an easily readable form what SQLite is trying to do with each statement it compiles, which is a tremendous help in debugging. Depending on how it is compiled, SQLite also has the capability of tracing the execution of the virtual machine - printing each virtual machine instruction and its result as it executes.

Re:Why is C faster than Java: git vs JGit by itmag on Friday January 13, 2012 @02:45AM (#3459621)
Off-topic but relevant: I've been looking for info on just how database software does what it does. Ie from parsing the SQL query to hitting the disk, and everything in between. Anyone got any links or books?
Re:Why is C faster than Java: git vs JGit by kragen on Friday January 13, 2012 @12:55PM (#3461569)
Gray and Reuter's Transaction Processing is absolutely superb, and it covers a good part of this stack, everything lower-level than query planning. However, it covers every approach to doing this. If you want to know how Postgres, say, does it, that's a lot less information, and may be more digestible.
Re:Why is C faster than Java: git vs JGit by itmag on Friday January 13, 2012 @03:10PM (#3462171)
Thanks. I am interested in the general theory of how every database does it; it bothers me that this area of software engineering is terra incognita to me.
Re:Why is C faster than Java: git vs JGit by andrewf on Friday January 13, 2012 @08:42AM (#3460477)
The sqlite source is well put together and pretty small. The (now pretty much obsolete) sqlite 2.x source was a lot smaller and might be a better starting point for pure learning purposes.

Bonus: in the sqlite command line tool, putting "EXPLAIN " before a query will dump out the VM commands that the query was converted to, without executing them.

Re:Why is C faster than Java: git vs JGit by csl on Friday January 13, 2012 @05:45AM (#3460024)
Any decent textbook on databases would cover most of this, with the possible exception of parsing SQL. It will likely have an in-depth discussion of data structures to reduce disk access.

I strongly recommend you read one such book more or less end-to-end.

HN: As with other areas of computer science, there is often a "canonical" book, like TAOCP or CLRS on algorithms. Is there any such book for databases?

Re:Why is C faster than Java: git vs JGit by sqlwiz on Friday January 13, 2012 @05:15AM (#3459951)
Nothing speaks like the source :) I recommend: http://www.postgresql.org/ftp/source/v9.1.2/