[Tarantool-patches] [PATCH v2 15/16] box: introduce prepared statements

Konstantin Osipov kostja.osipov at gmail.com
Wed Dec 4 15:13:46 MSK 2019


* Nikita Pettik <korablev at tarantool.org> [19/11/21 10:00]:
> This patch introduces local prepared statements. Support of prepared
> statements in IProto protocol and netbox is added in the next patch.
> 
> Prepared statement is an opaque instance of SQL Virtual Machine. It can
> be executed several times without necessity of query recompilation. To
> achieve this one can use box.prepare(...) function. It takes string of
> SQL query to be prepared; returns extended set of meta-information
> including statement's string, parameter's types and names, types and
> names of columns of the resulting set, count of parameters to be bound.
> Lua object representing result of :prepare() invocation also features method
> :execute(). It corresponds to box.execute(stmt.sql_str), i.e. automatically
> substitutes string of prepared statement to be executed. Statements are
> held in prepared statement cache - for details see previous commit.
> After schema changes all prepared statement located in cache are
> considered to be expired - they are re-prepared automatically on demand.
> It is worth noting that box.execute() always attempts at finding
> statement to be executed in prepared statement cache. Thus, once statement
> is prepared, both box.execute() and :execute() methods will execute
> already compiled statement.
> 
> SQL cache memory limit is regulated by box{sql_cache_size} which can be
> set dynamically. Setting it to 0 completely erases cache.
> 
> Part of #2592

Turned out to be not complex at all, eh?

Generally, LGTM (will give it another look).

The biggest issue so far I see with the entire series is effects
of schema version changes and cache size changes on
performance/correctness. I'll need to give it some more thought.


-- 
Konstantin Osipov, Moscow, Russia


More information about the Tarantool-patches mailing list