SQLite Forum

Why SQLite Uses Bytecode
Login

Why SQLite Uses Bytecode

(1) By Gwendal Roué (groue) on 2024-04-30 10:37:57 [source]

Hello,

Thank you for writing https://sqlite.org/draft/whybytecode.html!

May I ask where the query optimizer fits in those schemas (bytecode vs tree-of-objects)? Is one technique easier to optimize than the other?

(2) By Gwendal Roué (groue) on 2024-04-30 10:40:11 in reply to 1 [link] [source]

Optimization is also frequently found in programming language compilers, and your article had me wonder if they were optimizing flat or tree-shaped structures.

(3) By Richard Hipp (drh) on 2024-04-30 10:48:39 in reply to 2 [link] [source]

Most optimization occurs in the AST, prior to bytecode generation. Only rarely is the bytecode ever changed after it has been generated. The big exception is this block of code: https://sqlite.org/src/info/0ef9638651b900?ln=7073-7188

(4) By SeverKetor on 2024-04-30 11:48:47 in reply to 3 [link] [source]

Just read the article linked by OP and found a couple nits to pick:

"The is probably a misuse of the term"
"would almost certainly have more than six column"

(5) By Bo Lindbergh (_blgl_) on 2024-04-30 12:19:17 in reply to 1 [link] [source]

Random thought: it's possible to write a non-recursive tree walker that uses an explicit stack. This would make it easy to stop and restart execution for each result row.

(6) By Richard Hipp (drh) on 2024-04-30 12:34:10 in reply to 5 [link] [source]

It is possible, yes, but it would not be fun. You would basically be creating and managing your own stack. It would be error-prone.