Re: ADO find method performance
- From: "Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom>
- Date: Sun, 18 Feb 2007 18:21:44 -0000
I am developing one application where i need to search for record in
the ado recordset. i am giving search crieteria on a indexed(ID)
field. depending upon that record i need to fetch other field values.
my ado record set is created though client side cursor. and it
contains 1 million data and it can be 10/20 millions of record. what i
do is i just create a client side recordset for that ID field along
with required other 3 fields. those 3 field values i need for an ID
value.
ADO find method works fine when record counts are less but it dies for
millions of record.
Is there any performant way to achieve this??
Yes dont do it.
Recordsets are _LOUSY_ containers
I almost never use any of the client-sided methods : find(), sort(),
filter()
They are okay for small-scale and possibly medium-scale in terms of number
of records - but they are bad for large scale - as you have found out.
find() is O(N) and never O(log N)
Instead you either should either
- read into a different container like something for C, C++, VB and do
searching within that, preferably binary searches
(for C using bsearch(), for C++ using a sorted vector and then
lower_bound())
- or alternatively, use SQL, dont build up a recordset but do the queries as
you need them.
For single objects, I try and use Record objects.
And Stored Procedures as well.
It is nearly always a mistake to replace a SQL query with a Recordset _AND_
glue code (filter, find, sort) to do the equivalent. The SQL query is nearly
always superior. The database engine is designed to retrieve data fast - so
what not put its power to good use? If you do not know SQL - now is a good
time to learn.
Cheers
Stephen Howe
.
- References:
- ADO find method performance
- From: Mr . Sajal
- ADO find method performance
- Prev by Date: Re: ADO find method performance
- Next by Date: Re: ADO find method performance
- Previous by thread: Re: ADO find method performance
- Index(es):
Relevant Pages
|
|