SQL slow to connect after sitting for a bit
I have the vb.net program and the MS SQL Server on the same machine (its a POS program)
If the POS sits for a little while, 10, 20 minutes.. the first sale to go through takes a good 20 seconds to save the info into the database.. any orders done right after are fast
when the "finish button" is clicked, it inserts or updates the customer info, then inserts the order info, then the order details.
3 different tables.
It then opens an rdlc to print....
using
Code:
Public conn As New SqlConnection(My.Settings.POSDataConnectionString)
the Settings is this (the Min Pool Size was just added.. Not sure if it will help?)
Code:
Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\POSData\POSData.mdf;Integrated Security=True;Min Pool Size=1;
I always open the connection (which if it already open) it doesnt open another
Code:
If conn.State <> ConnectionState.Open Then
conn.Open()
End If
and then close it after..
is there something I can do? can I keep it open? just call the open each time to make sure its open.. and only close it when the app closes? Im also wondering if the rdlc (report viewer report) could be the delay.
Re: SQL slow to connect after sitting for a bit
You shouldn't need to hold the connection open. Connection Pooling will handle that for you.
I think the RDLC is more likely to be the problem as it's served by IIS. I don't understand the exact mechanism but it does do some sort of caching of recent activities so that it can serve them up faster. I'm guessing you're leaving it long enough between requests to have it fall out of that cache.
Re: SQL slow to connect after sitting for a bit
yeah digging around last night seem to point to that....
Anyone have any ideas about that?