473,569 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

large SELECT with ORDER BY very slow (only in ado.net)

Hello,

I have a problem that actually doesn't even make sense.
I have 4 million rows in my database. I want to get all records into a
DataReader and then read. So if I do it in DAO (either in VB or MFC C++)
it takes around 1 second to get the recordset and then around 10-15
seconds to iterate through the recordset. This speed remains the same even
if I incorporate an ORDER BY clause:
SELECT * FROM myTable ORDER BY customer_id, order_Date;
Without the ORDER BY statement i obtain the same speed in C# using
ado.net. I tested the four possibilities:
1. using OLE DB data provider with Ms Access.
2. using ODBC data provider with Ms Access.
3. using ODBC data provider with Sql Server.
4. using SqlClient data provider with Sql Server.

BUT, when I incorporated the ORDER BY clause each of the first three took
around 3 minutes!!! (the forth was around 30 seconds which is still very
very slow compared to the DAO (which is an older technology and depricated
in vs.net). NOTE: all the extra time is from the method
DbCommand.Execu teReader() not from iterating through the dataReader.
It's not a question of reducing the size of data i retrieve or indexing
the relevant fields in the database as I want to achieve with ado.net the
same speed I get with DAO. In my experiment I use the same database, same
tables and corresponding objects (as a RecordSet in DAO is the same as a
DataReader in ado.net).
Another thing i noticed is that i use a dynaset in DAO (which no longer
exists in ado.net). Still need to find a solution for this problem.

Thanks,
Dror

Jul 21 '05 #1
3 4825
On Mon, 27 Dec 2004 06:56:24 -0500, "dror" <dr*****@gmail. com> wrote:

¤ Hello,
¤
¤ I have a problem that actually doesn't even make sense.
¤ I have 4 million rows in my database. I want to get all records into a
¤ DataReader and then read. So if I do it in DAO (either in VB or MFC C++)
¤ it takes around 1 second to get the recordset and then around 10-15
¤ seconds to iterate through the recordset. This speed remains the same even
¤ if I incorporate an ORDER BY clause:
¤ SELECT * FROM myTable ORDER BY customer_id, order_Date;
¤ Without the ORDER BY statement i obtain the same speed in C# using
¤ ado.net. I tested the four possibilities:
¤ 1. using OLE DB data provider with Ms Access.
¤ 2. using ODBC data provider with Ms Access.
¤ 3. using ODBC data provider with Sql Server.
¤ 4. using SqlClient data provider with Sql Server.
¤
¤ BUT, when I incorporated the ORDER BY clause each of the first three took
¤ around 3 minutes!!! (the forth was around 30 seconds which is still very
¤ very slow compared to the DAO (which is an older technology and depricated
¤ in vs.net). NOTE: all the extra time is from the method
¤ DbCommand.Execu teReader() not from iterating through the dataReader.
¤ It's not a question of reducing the size of data i retrieve or indexing
¤ the relevant fields in the database as I want to achieve with ado.net the
¤ same speed I get with DAO. In my experiment I use the same database, same
¤ tables and corresponding objects (as a RecordSet in DAO is the same as a
¤ DataReader in ado.net).
¤ Another thing i noticed is that i use a dynaset in DAO (which no longer
¤ exists in ado.net). Still need to find a solution for this problem.

The problem is probably due to the fact that ADO.NET will attempt to return the *data* for all rows
(to the client) upon execution of the query, and then disconnect. A DAO Dynaset Recordset type, on
the other hand, will only return a small subset of the data (and all keys), remain connected and
retrieve additional data as it is requested through the Recordset object.

ADO.NET doesn't support dynamic result sets. The result sets returned are essentially disconnected.
The closest equivalent in DAO to an ADO.NET DataReader would be a Snapshot (forward-only).
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #2
Hi,
Thanks for the reply,
I've been experimenting with this for the last few days. I would like to
move to ado.net (DAO has been depricated). I've tried odbc (mssql &
access), oledb (mssql & access) and SqlClient providers and none reach the
performance of DAO's dynaset. I understand the reason for that, as you
explained, but I still need to find a solution as on one hand DAO is
depricated and on the other ado.net's performance is poor (even for
smaller sizes of queries DAO performs better, and not to mention the
performance of filling a DataSet which is even slower). What should I do
in this case? What API should I use? Btw, even legacy ADO performs slower
with dynamic recordset. Why is the idea behind dynaset being depricated,
is microsoft giving up on fast technology? What other API can be used that
runs fast?

Dror

Jul 21 '05 #3
On Mon, 27 Dec 2004 15:55:34 -0500, "dror" <dr*****@gmail. com> wrote:

¤ Hi,
¤ Thanks for the reply,
¤ I've been experimenting with this for the last few days. I would like to
¤ move to ado.net (DAO has been depricated). I've tried odbc (mssql &
¤ access), oledb (mssql & access) and SqlClient providers and none reach the
¤ performance of DAO's dynaset. I understand the reason for that, as you
¤ explained, but I still need to find a solution as on one hand DAO is
¤ depricated and on the other ado.net's performance is poor (even for
¤ smaller sizes of queries DAO performs better, and not to mention the
¤ performance of filling a DataSet which is even slower). What should I do
¤ in this case? What API should I use? Btw, even legacy ADO performs slower
¤ with dynamic recordset. Why is the idea behind dynaset being depricated,
¤ is microsoft giving up on fast technology? What other API can be used that
¤ runs fast?

My suggestion would be to implement a paging mechanism similar to what you see
in web pages that display long lists of data. You can restrict your queries to
return only a certain number of rows at a time. If you're using SQL Server or
Access, the TOP keyword would do this. Whenever you need to display data beyond
the end of your current dataset, query the database and select all data where
the field you are ordering by is greater than the value of that field for the
last row of the current dataset. This is somewhat similar to how DAO works with
Dynasets, although all the work is performed under the covers.

With respect to your other questions, ADO is slower than DAO, primarily because
DAO talks directly to the Jet database engine while ADO operates through an
additional data access layer called OLEDB.

In addition, Microsoft has slowly moved away from the concept of persistent
connections and server-side cursors. With the movement toward web development
and thin clients the emphasis has been more toward the concept of data
manipulation in a disconnected environment, either at the server application
level or desktop client application level, significantly reducing the usage of
database resources. Connection resources only exist for the time in which an
update or retrieval of data is required. The middle-man, database cursors, have
been more or less rendered obsolete.

I don't think this is necessarily the correct approach as there are applications
that would significantly benefit from the features present in data access
mechanisms such as DAO.
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2625
by: StealthBananaT | last post by:
My database has two tables - films has 10,000 records and reviews has 20,000 records. Whenever I try to list all the films and the count of its reviews, MySQL locks and I have to restart the service. Here's the SQL... SELECT films.*, COUNT(reviews.id) FROM films LEFT JOIN reviews ON films.id = reviews.filmID GROUP BY films.id LIMIT 0,...
1
2914
by: Philipp K. Janert, Ph.D. | last post by:
Dear All! I am trying to load a relatively large table (about 1 Million rows) into an sqlite table, which is kept in memory. The load process is very slow - on the order of 15 minutes or so. I am accessing sqlite from Python, using the pysqlite driver. I am loading all records first using cx.execute( "insert ..." ). Only once I have run...
3
1575
by: Jeremy Howard | last post by:
I am finding delete queries on large InnoDB tables very slow - are there ways to speed this up? I have a table with about 100 million rows: I am trying to delete just a few of these rows (the following select takes a couple of seconds): > SELECT count(*) -> FROM UserSnap
5
3358
by: Thomas Andersson | last post by:
Hi, I am trying to find a working solution for download of large files (400-800 MB)... But this seems almost impossible to find a working example. I have tried Response.Transmitfile, this works for some people…but in my case the server reset the connection after approx. 20 minutes and sometimes after 7-8 minutes…the download speed...
4
5354
by: sherkozmo | last post by:
SQL2000 - AccessXP I built an adp file with a stored procedure from SQL as follows: SELECT * FROM Z_mis_sjk_job_code_access WHERE job_code=@JobCode UNION ALL SELECT * FROM Z_mis_sjk_job_code_access_mkey WHERE job_code=@JobCode ORDER BY app_only, submenu_number, menu_routine_number,
3
6317
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On these files teh time that it takes until the client displays the Save As dialog can be extrordinarily long (3+ minutes). I don't understand why. I...
3
323
by: dror | last post by:
Hello, I have a problem that actually doesn't even make sense. I have 4 million rows in my database. I want to get all records into a DataReader and then read. So if I do it in DAO (either in VB or MFC C++) it takes around 1 second to get the recordset and then around 10-15 seconds to iterate through the recordset. This speed remains the...
0
3375
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server 2005 and the likes of it. So This one works with SQL2000 What do you think?
2
1761
by: ARC | last post by:
I'm testing a user's db that contains a very large number of records. I have an invoice screen, with an invoice select dropdown box that shows all invoices, and the customer's name, etc. With 80,000+ invoices in this particular db, clicking the dropdown is painfully slow accross a network only (I'm testing on a wireless, so it's even slower...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.