Lag in application with respect to database

L

Loogie

I am using VB.Net SP1 Compact Framework 2.0 with MS SQL Compact Server
2005.

I notice that when my app opens its first database there is a slight lag
(3 or 4 seconds at the most).

However any subsequent databases I open there is no lag whatsoever.

Any thoughts on why this happens? Here is my standard open and close of
a db:

' Create and open connection.
Dim ssceconn As New SqlCeConnection("Data Source = \Program
Files\data\" & Me.Text & ".sdf")
ssceconn.Open()

do stuff here

' Close the connection
ssceconn.Close()
ssceconn.Dispose()
ssceconn = Nothing

All of the db's are small < 100 records. None will ever be much larger
than 500 records.

I have been thinking that I should just have a db open and then close at
the launch of my app but that seems a rather odd way to do things.

Thanks in advance for any feedback.

:L
 
L

Loogie

The CLR has to JIT all of the SqlCe assemblies the first time.

Being a new developer, I am ignorant of what CLR and JIT mean. Does my
idea of opening a database and closing it at app launch seem ok?

Thanks

:L
 
G

Guest

The CLR is the "Common Language Runtime". JIT is Just In Time compilation.
If you're going to do managed development, you need to know and understand
these terms, so I'd highly recommend you go online an do some research.

When the SqlCe assemblies are loaded, they must be compiled. That takes
time (this is the same reason CF apps take a little while to start up as
well). You'll have to pay this price at some point - it's your choice (via
code) when.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
L

Loogie

The CLR is the "Common Language Runtime". JIT is Just In Time compilation.
If you're going to do managed development, you need to know and understand
these terms, so I'd highly recommend you go online an do some research.

When the SqlCe assemblies are loaded, they must be compiled. That takes
time (this is the same reason CF apps take a little while to start up as
well). You'll have to pay this price at some point - it's your choice (via
code) when.

Thanks Chris. Your help on here is appreciated.

:L
 
G

Guest

Apart from CLR time consumption, SQL CE also does good amount of work when
you open the database for the first time and also it will spend some time
during the last connection close (across process). So if you have single
process accessing the database, instead of opening and closing the database
everytime, have a dummy connection open at the starting of the app (and close
it when the app ends). Another alternative it to have Connection.Open and
Close at logical units instead of everytime you access the DB.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top