3.7. Command Preparation, Cancellation, Timeouts, and Cleanup

The IDbCommand interface has a method called Prepare, which makes a round-trip to the database to tell the database to Prepare the statement and cache it in its query cache for later use. Because all modern databases cache query plans without asking, the only thing Prepare buys you with most databases is a little faster execution speed the first time the query is executed; you also get some control over the lifetime of the query plan. This comes at the expense of a database round-trip, so its usefulness is questionable—although, on a busy system, a statement that isn't prepared could have its query plan flushed, depending on the query cache management policy of the database. Although ...

Get Essential ADO.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.