3

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. Non the less, if I need to build the DbCommand my self and then keep it somewhere, how can I use the command with Dapper?

Aryéh Radlé
  • 1,310
  • 14
  • 31

1 Answers1

4

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

  • 1
    Well, that makes sense. Maybe plain ADO.net will work for me in this specific scenario. Thanks – Aryéh Radlé Dec 27 '17 at 14:20
  • Thanks for sharing this. This is the best explanation I've read so far about the benefits and downsides of the Prepare() statement in ADO.NET. – Andreas Sep 21 '21 at 18:21