comdb2 icon indicating copy to clipboard operation
comdb2 copied to clipboard

{172658452}: Speeding up dohast bound parameter processing

Open riverszhang89 opened this issue 2 years ago • 0 comments

Rebinding parameters may cause SQLite to recompile the statement in the hope of a better query plan. A new yet identical (?) AST is parsed out during the process, as well.

While it makes sense to recode the statement after parameters are changed, it seems a bit wasteful to generate another identical AST. Hence in this patch, the dohast struct is relocated from the parser to the sqlite3 db handle, and is reused whenever possible.

In addition, a lookaside hash table for bound parameter names, is added in this patch, turning an O(N^2) search into an O(1) hash table lookup. This change greatly speeds up AST parsing for a large number of bound parameters.

riverszhang89 avatar Aug 10 '23 16:08 riverszhang89