fortik

I am accessing a table in MS SQL Express by mean of a simple select and the result is in a "dim dr as OdbcDataReader". Then i read all records in this way

do while dr.read

dim i as integer=dr.getInt32(1)

loop

I put this thread in a background worker and it is soooooooo slow

The same code in a PC pentium 4 3Ghz is very fast (WIndows 2000).

On my laptop centrino 1.7 GHz (Windows XP prof edition) it is very slow.

I have notice that on PC if i watch to task manager the task is hardly working (use a lot

of resource) while on laptop it is very slow, it uses only 2% of resources.

So i tried to change priority of task in the routine putting as first instruction in the background worker event dowork the following instruction

System.Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.Highest

I also tried to create a thread and setting priority. NOthing change.

Where is my error

Many thanks to anybody will want to help me

Best regards

Fortik




Re: .NET Framework Data Access and Storage why so slow?

Martin Xie - MSFT

Please try the code:

dim i as integer

do while dr.read

i=dr.getInt32(1)

loop

In addition, the following thread might give your a little of inspiration.

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1518857&SiteID=1

Hope that helps!






Re: .NET Framework Data Access and Storage why so slow?

fortik

I have tried already different solution. It seems that it is slow on my laptop. Very slow!

On PC it is fast either on Windows 2000 or XP






Re: .NET Framework Data Access and Storage why so slow?

ThE_lOtUs

It might be your query/database that is slowing down things




Re: .NET Framework Data Access and Storage why so slow?

fortik

no, the query is done very fast, it is reading the odbcdatareader that is slow.

The resources used by the computer during the all thread are very few on laptop...something like 5-6%

while running on PC it is almost 90% of resources...as seen by means of task manager.






Re: .NET Framework Data Access and Storage why so slow?

William Vaughn

1) When accessing SQL Server with any version of ADO you should use a provider-specific provider if one is available. In the case of ADO.NET this means using SqlClient. It's the fastest, safest and lightest. It also exposes all SQL Server functionality.

2) When running an application on a Windows system that has to share RAM and CPU time with other applications, you have to ensure that the application is given enough CPU time and RAM to do the job. How much RAM is on the laptop What applications are running when you run this test Is the SQLExpress instance on the laptop or being accessed via the net






Re: .NET Framework Data Access and Storage why so slow?

fortik

I am accessing with adodbdatareader.Is it not correct

The RAM is 1 GB, sqlexpress is running on the laptop

The query is executed in few time, then the loop to read the data is put

in a thread and the thread consumes few resources while almost all are of idle task.

On the contrary, the same code on a PC with less ram 256 MB is very fast, as i expected

consuming all resources of the machine






Re: .NET Framework Data Access and Storage why so slow?

William Vaughn

You indicated that you were using ODBC.

You should be referencing the SqlClient.SqlDataReader

Consider that the network interface to the server can also play a role here.






Re: .NET Framework Data Access and Storage why so slow?

fortik

yes, i changed to sqlclient

it is incredible fast.

Many thanks






Re: .NET Framework Data Access and Storage why so slow?

Matt Neerincx

This is very strange behavior. It sounds as if the thread is starved somehow, I agree. What I would suspect here as a first stab is something is blocking network IO. You can verify this by doing things like:

1. Run same code on main thread, is it still slow

2. Write a simple console app that all it does is open connection and read records, is it still slow

Certain things on the PC could be interupting network IO, like virus scanning utilities, etc...

Also, just try to copy a huge file to the same machine, is it slow, etc...

You could have a really lossy network connection requiring lots of retries, this could slow it down. I would do things like run a network sniffer (Microsoft has Netmon, there is also Ethereal that is 3rd party and free and pretty good). In the network sniffer you can see exactly when the packets come across the wire and if the client is holding back the data or not (but this requires some knowledge of tcp-ip traffic control).






Re: .NET Framework Data Access and Storage why so slow?

fortik

I changed from odbc.odbcdatareader to sqlclient.sqlclientreader and the speed of system dramaticly increased.

Anyway, on pc the odbc was fast....

all is in local on laptop as in pc,

Dim mr As SqlClient.SqlDataReader

......

.......

dim i as integer= mr.GetInt32(1)

if mr is of type Odbc.OdbcDataReader, the same instruction

dim i as integer= mr.GetInt32(1)

is at least 100 times slower

Do you know any reason






Re: .NET Framework Data Access and Storage why so slow?

Matt Neerincx

Ahh yes, I remember this one now. This is a classic perf issue.

The reason it is significantly slower is because you have odbc tracing turned on. Turn off odbc tracing!

Go to control panel | administrative tools then open Data Sources (ODBC).

Select Tracing tab. If button says "Stop tracing now" click the button.

This will turn it off. You will also want to delete the tracing file as well as it is probably huge!






Re: .NET Framework Data Access and Storage why so slow?

fortik

Many thanx.

You are right, the analyzer was active but i did not actiuvate it :-(

Anyway i changed from odbc to sqlclient already.i will test

later on old software.

Best regards