PC Review


Reply
Thread Tools Rate Thread

Access takes 24-35 seconds while SQL Server takes only 2-3 seconds

 
 
=?Utf-8?B?QXJpZg==?=
Guest
Posts: n/a
 
      7th Nov 2005
I test my C# applicaiton both with Access and SQL Server database. I note
that the following code snippets takes 24-35 seconds with Access database
while takes only 2-3 seconds with SQL Server to fetch same number of records
(80,000 records).

//with Access Database
this.da = new OdbcDataAdapter("select Barcode, Description from
Items_Detail", DB.cn);

//with SQL Server
this.da = new SqlDataAdapter("select Barcode, Description from
Items_Detail", DB.cn);

//common code
this.da.Fill(this.ds, "Get_Quantity_Result");
grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");


for my customer simplicity i want to give him solution with Access database
but with this un-acceptable delay i can't do this.

Please help in identifying that why it is taking much time to fetch records
from Access database.

Arif.


 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      7th Nov 2005
Do you have indexes on the relevant fields?

Are you running over a network?

With Access (presumably you mean JET database engine) all the work is being
done by the local computer, so if you are running over a network the
database the process has to download data from the file server, process
that, and get the necessary records.

With SQL, the processing takes place on the server and the requested records
are sent in a batch.

SQL Server also caches information in RAM so that can significantly impact
performance on subsequent calls for the same or similar data.



"Arif" <(E-Mail Removed)> wrote in message
news:0A502394-A473-48AE-95E6-(E-Mail Removed)...
>I test my C# applicaiton both with Access and SQL Server database. I note
> that the following code snippets takes 24-35 seconds with Access database
> while takes only 2-3 seconds with SQL Server to fetch same number of
> records
> (80,000 records).
>
> //with Access Database
> this.da = new OdbcDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //with SQL Server
> this.da = new SqlDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //common code
> this.da.Fill(this.ds, "Get_Quantity_Result");
> grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
>
>
> for my customer simplicity i want to give him solution with Access
> database
> but with this un-acceptable delay i can't do this.
>
> Please help in identifying that why it is taking much time to fetch
> records
> from Access database.
>
> Arif.
>
>



 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      7th Nov 2005
Arif wrote:

>I test my C# applicaiton both with Access and SQL Server database. I note
>that the following code snippets takes 24-35 seconds with Access database
>while takes only 2-3 seconds with SQL Server to fetch same number of records
>(80,000 records).
>
>//with Access Database
>this.da = new OdbcDataAdapter("select Barcode, Description from
>Items_Detail", DB.cn);
>
>//with SQL Server
>this.da = new SqlDataAdapter("select Barcode, Description from
>Items_Detail", DB.cn);
>
>//common code
>this.da.Fill(this.ds, "Get_Quantity_Result");
>grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
>
>
>for my customer simplicity i want to give him solution with Access database
>but with this un-acceptable delay i can't do this.
>
>Please help in identifying that why it is taking much time to fetch records
>from Access database.



I want to argue the validity of your test. It is near
meaningless to fetch 80,000 records at one time. You are
never going to use more than a single, or at most a few,
records in any operation so your query should use a where
clause to severly filter the dataset.

As John mentioned, caching will probably play a significant
role if you run the query multiple times. I don't know what
the OdbcDataAdapter does, but I would not be surprised if
the local machine did not cache the data too.

One other point, the sql statement must be compiled and if
this is done in the local machine (as with DAO) there may be
a significant delay while table statistics are retrieved and
the query's strategy is determined. If you can use a
presaved query, it may be quicker.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
David C. Holley
Guest
Posts: n/a
 
      7th Nov 2005
I concur with MB's issue with the 'test'. You're not testing a real
world scenario.

Marshall Barton wrote:
> Arif wrote:
>
>
>>I test my C# applicaiton both with Access and SQL Server database. I note
>>that the following code snippets takes 24-35 seconds with Access database
>>while takes only 2-3 seconds with SQL Server to fetch same number of records
>>(80,000 records).
>>
>>//with Access Database
>>this.da = new OdbcDataAdapter("select Barcode, Description from
>>Items_Detail", DB.cn);
>>
>>//with SQL Server
>>this.da = new SqlDataAdapter("select Barcode, Description from
>>Items_Detail", DB.cn);
>>
>>//common code
>>this.da.Fill(this.ds, "Get_Quantity_Result");
>>grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
>>
>>
>>for my customer simplicity i want to give him solution with Access database
>>but with this un-acceptable delay i can't do this.
>>
>>Please help in identifying that why it is taking much time to fetch records

>
>>from Access database.

>
>
> I want to argue the validity of your test. It is near
> meaningless to fetch 80,000 records at one time. You are
> never going to use more than a single, or at most a few,
> records in any operation so your query should use a where
> clause to severly filter the dataset.
>
> As John mentioned, caching will probably play a significant
> role if you run the query multiple times. I don't know what
> the OdbcDataAdapter does, but I would not be surprised if
> the local machine did not cache the data too.
>
> One other point, the sql statement must be compiled and if
> this is done in the local machine (as with DAO) there may be
> a significant delay while table statistics are retrieved and
> the query's strategy is determined. If you can use a
> presaved query, it may be quicker.
>

 
Reply With Quote
 
Brendan Reynolds
Guest
Posts: n/a
 
      7th Nov 2005
In addition to the points that others have made, you may get better
performance using the OleDb data provider rather than the ODBC data provider
with a JET database.

--
Brendan Reynolds

"Arif" <(E-Mail Removed)> wrote in message
news:0A502394-A473-48AE-95E6-(E-Mail Removed)...
>I test my C# applicaiton both with Access and SQL Server database. I note
> that the following code snippets takes 24-35 seconds with Access database
> while takes only 2-3 seconds with SQL Server to fetch same number of
> records
> (80,000 records).
>
> //with Access Database
> this.da = new OdbcDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //with SQL Server
> this.da = new SqlDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //common code
> this.da.Fill(this.ds, "Get_Quantity_Result");
> grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
>
>
> for my customer simplicity i want to give him solution with Access
> database
> but with this un-acceptable delay i can't do this.
>
> Please help in identifying that why it is taking much time to fetch
> records
> from Access database.
>
> Arif.
>
>



 
Reply With Quote
 
Albert D.Kallal
Guest
Posts: n/a
 
      8th Nov 2005
You don't give any details of your setup here (like is a network involved
for example??).

If a network is involved, then you might try opening a dummy table in your
code BEFORE you try and execute your query.
(so, in some previous code, open up a table in the back end....say a tiny
table with 1 record...keep it open, and THEN try
your query.

Forcing (keeping) a connection open can eliminate many delays.....give this
idea a try...



--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)
http://www.members.shaw.ca/AlbertKallal


 
Reply With Quote
 
=?Utf-8?B?QXJpZg==?=
Guest
Posts: n/a
 
      8th Nov 2005
Thanks John for your kind support,

I have 10 columns with only one primary key column.
I am using on my local PC.

arif.


"John Spencer" wrote:

> Do you have indexes on the relevant fields?
>
> Are you running over a network?
>
> With Access (presumably you mean JET database engine) all the work is being
> done by the local computer, so if you are running over a network the
> database the process has to download data from the file server, process
> that, and get the necessary records.
>
> With SQL, the processing takes place on the server and the requested records
> are sent in a batch.
>
> SQL Server also caches information in RAM so that can significantly impact
> performance on subsequent calls for the same or similar data.
>
>
>
> "Arif" <(E-Mail Removed)> wrote in message
> news:0A502394-A473-48AE-95E6-(E-Mail Removed)...
> >I test my C# applicaiton both with Access and SQL Server database. I note
> > that the following code snippets takes 24-35 seconds with Access database
> > while takes only 2-3 seconds with SQL Server to fetch same number of
> > records
> > (80,000 records).
> >
> > //with Access Database
> > this.da = new OdbcDataAdapter("select Barcode, Description from
> > Items_Detail", DB.cn);
> >
> > //with SQL Server
> > this.da = new SqlDataAdapter("select Barcode, Description from
> > Items_Detail", DB.cn);
> >
> > //common code
> > this.da.Fill(this.ds, "Get_Quantity_Result");
> > grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
> >
> >
> > for my customer simplicity i want to give him solution with Access
> > database
> > but with this un-acceptable delay i can't do this.
> >
> > Please help in identifying that why it is taking much time to fetch
> > records
> > from Access database.
> >
> > Arif.
> >
> >

>
>
>

 
Reply With Quote
 
Michel Walsh
Guest
Posts: n/a
 
      8th Nov 2005
Hi,


I don't see any perceptible difference, here, within the two procedures:


=================
private void button1_Click(object sender, EventArgs e)
{
string conn;
conn = @"Data Source=(local)\beta;" +
"Initial Catalog=Testings;Integrated Security=SSPI;";
SqlConnection cn = new SqlConnection(conn);
SqlDataAdapter adapter = new SqlDataAdapter(cn.CreateCommand());
DataSet dataSet = new DataSet();
adapter.SelectCommand.CommandText = "SELECT * FROM iotas WHERE
iota < 10000";
adapter.Fill(dataSet);

}

private void button2_Click(object sender, EventArgs e)
{
string conn;
conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\db1.mdb;";
OleDbConnection cn = new OleDbConnection(conn);
OleDbDataAdapter adapter = new
OleDbDataAdapter(cn.CreateCommand());
DataSet dataSet = new DataSet();
adapter.SelectCommand.CommandText = "SELECT * FROM iotas WHERE
iota < 10000";
adapter.Fill(dataSet);
}
===================


Is it possible that your two databases are different in their tables, more
precisely, in the number of records they have stored ?

Is it possible that your MS SQL Server version LIMIT the number of rows
returned (which is usual, by default, on some configuration) ?



Hoping it may help,
Vanderghast, Access MVP

"Arif" <(E-Mail Removed)> wrote in message
news:0A502394-A473-48AE-95E6-(E-Mail Removed)...
>I test my C# applicaiton both with Access and SQL Server database. I note
> that the following code snippets takes 24-35 seconds with Access database
> while takes only 2-3 seconds with SQL Server to fetch same number of
> records
> (80,000 records).
>
> //with Access Database
> this.da = new OdbcDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //with SQL Server
> this.da = new SqlDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //common code
> this.da.Fill(this.ds, "Get_Quantity_Result");
> grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
>
>
> for my customer simplicity i want to give him solution with Access
> database
> but with this un-acceptable delay i can't do this.
>
> Please help in identifying that why it is taking much time to fetch
> records
> from Access database.
>
> Arif.
>
>



 
Reply With Quote
 
=?Utf-8?B?QXJpZg==?=
Guest
Posts: n/a
 
      10th Nov 2005
Thanks Brendan Reynolds.

Yes, using OleDb data provider rather than the ODBC data provider i see much
more better performance. Now it is also taking the same time taken by SQL
Server.
And it solved my problem.

Tanks again Brendan Reynolds.

arif.

"Brendan Reynolds" wrote:

> In addition to the points that others have made, you may get better
> performance using the OleDb data provider rather than the ODBC data provider
> with a JET database.
>
> --
> Brendan Reynolds
>
> "Arif" <(E-Mail Removed)> wrote in message
> news:0A502394-A473-48AE-95E6-(E-Mail Removed)...
> >I test my C# applicaiton both with Access and SQL Server database. I note
> > that the following code snippets takes 24-35 seconds with Access database
> > while takes only 2-3 seconds with SQL Server to fetch same number of
> > records
> > (80,000 records).
> >
> > //with Access Database
> > this.da = new OdbcDataAdapter("select Barcode, Description from
> > Items_Detail", DB.cn);
> >
> > //with SQL Server
> > this.da = new SqlDataAdapter("select Barcode, Description from
> > Items_Detail", DB.cn);
> >
> > //common code
> > this.da.Fill(this.ds, "Get_Quantity_Result");
> > grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
> >
> >
> > for my customer simplicity i want to give him solution with Access
> > database
> > but with this un-acceptable delay i can't do this.
> >
> > Please help in identifying that why it is taking much time to fetch
> > records
> > from Access database.
> >
> > Arif.
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?RXhwcmVzc21hbg==?=
Guest
Posts: n/a
 
      4th Mar 2007


"Arif" wrote:

> I test my C# applicaiton both with Access and SQL Server database. I note
> that the following code snippets takes 24-35 seconds with Access database
> while takes only 2-3 seconds with SQL Server to fetch same number of records
> (80,000 records).
>
> //with Access Database
> this.da = new OdbcDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //with SQL Server
> this.da = new SqlDataAdapter("select Barcode, Description from
> Items_Detail", DB.cn);
>
> //common code
> this.da.Fill(this.ds, "Get_Quantity_Result");
> grd_All_Recs.SetDataBinding(this.ds, "Get_Quantity_Result");
>
>
> for my customer simplicity i want to give him solution with Access database
> but with this un-acceptable delay i can't do this.
>
> Please help in identifying that why it is taking much time to fetch records
> from Access database.
>
> Arif.
>
>

Try a Where clause using the Primary key.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GetProcessesByName takes 10-15 seconds? Andy Microsoft C# .NET 5 8th Aug 2005 07:30 PM
Word takes 20 seconds to load and 15 seconds to unload. Why? =?Utf-8?B?Wi1SZXk=?= Microsoft Word Document Management 1 30th Apr 2005 12:25 AM
Word takes 20 seconds to start, Excel takes 1 second. Why? =?Utf-8?B?Wi1SZXk=?= Microsoft Word Document Management 1 9th Apr 2005 01:10 AM
Booting takes 42 seconds =?Utf-8?B?U3JpdmF0aHNhbg==?= Windows XP Embedded 2 21st Feb 2005 08:33 PM
Save takes seconds vs. SaveAs/Save As takes minutes Andrew H Microsoft Excel Programming 0 17th Aug 2004 07:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:38 PM.