SQLite3 中的“预先准备"语句? [英] 'Pre-prepared' statements in SQLite3?

查看:34
本文介绍了SQLite3 中的“预先准备"语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有固定查询集的内存受限嵌入式系统中使用 SQLite,如果可以预先准备"查询,似乎可以节省代码和数据.也就是说,prepared statement是在build时由(相当于)sqlite3_prepare_v2()产生的,运行时只需要调用_bind()、_step()等,引用一个或多个sqlite3_stmt* 有效静态数据的指针.整个 SQL 解析(和查询计划?)引擎可以从目标中删除.

我意识到 sqlite3_stmt* 指针背后隐藏着相当大的复杂性,并且这对于当前的 sqlite3 实现来说不太可能实际 - 但这个概念是否可行?

解决方案

这是 讨论 于 2006 年在 SQLite 用户邮件列表中.当时 D. Richard Hipp 支持 SQLite 的商业版本,该版本在精简的目标上运行编译语句,该版本没有任何 SQL 解析器.或许你可以通过 hwaci 看看这个产品是否仍然可用.

Using SQLite in a memory-constrained embedded system with a fixed set of queries, it seems that code and data savings could be made if the queries could be 'pre-prepared'. That is, the prepared statement is produced by (an equivalent of) sqlite3_prepare_v2() at build time, and only _bind(), _step() etc need to be called at runtime, referencing one or more sqlite3_stmt* pointers that are effectively static data. The entire SQL parsing (and query planning?) engine could be eliminated from the target.

I realise that there is considerable complexity hidden behind the sqlite3_stmt* pointer, and that this is highly unlikely to be practical with the current sqlite3 implementation - but is the concept feasible?

解决方案

This was discussed on the SQLite-users mailing list in 2006. At that time D. Richard Hipp supported a commercial version of SQLite that ran compiled statements on a stripped down target, which did not have any SQL parser. Perhaps you could check with hwaci to see if this product is still available.

这篇关于SQLite3 中的“预先准备"语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆