Fast DB access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm trying to implement a fast database access infrastructure.
Basically what I have is a singleton object which provides methods to get
sqlcommand's, from which you can get cursors or execute
updates/insert/deletes.
Upon application startup

- All possible SQL sentences are registered in the singleton (there's like
20-30 of them for now) using a short name, something like

DBAccess.addSentence ("PROD", "SELECT DESCRIPTION,PRICE FROM PRODUCTS")

Each command is linked to a SQL sentence. When the application needs a
command, the singleton checks if there's one already built for the sentence
(the application passes the short name as a parameter) and whether it's free
or not. If needed, a sqlcommand is built and added to the pool, otherwise an
existing one is returned.

The application uses the command normally and once it's done with it calls
the singleton to let it know it can reuse it.

So far it seems to work great, and it's very fast. I'm worried about the
possibility of SQL resources getting exhausted, though. Is there a limit on
the number of SQLcommand objects that can exist at a given time? I need one
for each difference SQL sentence my application has. Works fine so far, but
what if the number grows?

Thanks.
 
The class System.Data.SqlClient.SqlCommand is a class that doesn't use
any system resources (Dispose method for this class does nothing,
constructor initiate only managed variables). You could easily use it as
many as how much memory you have.

HTH,
Sergey
 
Back
Top