Any statement that has been stepped but not to completion will hold open the transaction on a connection. This may interfere with your expectations. Clearing bindings as a precaution will prevent inadvertent re-use of old bindings. The statement may have to be reset first, see documentation. Statements prepared with the V2 (or later) interface will recompile if necessary.
-----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von carsten.muencheberg Gesendet: Montag, 16. Dezember 2019 22:38 An: sqlite-users@mailinglists.sqlite.org Betreff: [EXTERNAL] [sqlite] Implementing a statement cache Hi, I am working on a generic cache for prepared statements and would like to make sure that I am not overlooking anything important. The cache is a simple map from an SQL string to a statement pointer. 1. When to call sqlite3_reset()? It looks like the safest and easiest approach is to call sqlite3_reset() immediately after retrieving a statement from the cache. Is there any disadvantage in regards to concurrency or performance in keeping dozens or hundreds of statements alive in a non reset state e.g. SELECT statements which have not stepped over all rows? 2. When to call sqlite3_clear_bindings()? If I understand correctly new values can be bound without clearing old ones first, but calling sqlite3_clear_bindings() can be a safeguard against accidentally executing a statement with old values? 3. When to clear the cache? I read that in some cases statements are automatically recompiled when a different value is bound to a parameter inside the WHERE clause. What about SQLITE_ENABLE_STAT4 and ANALYZE, would it make sense to clear the cache afterwards or can we trust SQLite to maintain existing statements under all circumstances? 4. Other ideas, comments? Thanks in advance. Carsten _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users