Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite .net provider & "prepare statement" functionality

Tags:

c#

sqlite

dapper

PREFACE

One can find a description of the SQLite's "Prepared Statement" functionality here.

SQLite command (SQLite provider for .NET) has a method "Prepare" with the following description:

Summary: Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards.

QUESTIONS

  1. In general, does SQLite's Prepared Statement functionality improve overall performance of the query, which is executed over and over again?
  2. Where the prepared statements are kept? How can I be sure that these prepared statements are in fact being used?
  3. How can I be sure that Dapper is utilizing these statements? (In my case, I use Dapper to run the same query several hundred times. The query fetches 10k results in each call, based on passed parameters).

EDIT:

Just've found this, which partially answers my question. Nonetheless, if I need to build the DbCommand myself and then keep it somewhere, how can I use the command with Dapper?

like image 743
Aryéh Radlé Avatar asked Feb 17 '26 10:02

Aryéh Radlé


1 Answers

It is entirely true to say that Dapper does not currently call Prepare().

You can read an extended explanation here

Long story short the main reason is: Dapper really, really doesn't want to store your connections, because it is designed with high concurrency in mind, and typically work in scenarios where the DbConnection is short-lived