Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the RecordCount faster

Status
Not open for further replies.

MelissaEvans

Programmer
Mar 8, 2001
39
0
0
US
I've come to the realization that I must use a Server Side cursor in an ADO connection (to a SQL Server 7.0 database, but this shouldn't be set in stone; my boss love to sell with Access and anything else that would make the customer happy). One customer has an extremely large table (100,000) and getting the cursor for it is pretty darn quick (i.e. 3 secs). The hard part is getting the darn recordcount. When it's a large recorset (i.e. > 32,000), it takes two minutes, plus. Does anyone know of any special, "sneaky," way to get the recordcount? Keep in mind, that the recordset I'm using isn't the whole table (so just knowing how many records are in the table isn't very helpful).

Thanks!
 
Why do you need the record count?

Are you doing
rs.movelast
lCount = rs.recordcount

If so

select count(The primary key field) AS HowMany from ...


lCount = rs("HowMany")


could be better Peter Meachem
peter@accuflight.com
 
select count([red]Select ... the recordset querey)[/red] From ...



MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
You're right, the &quot;select count(*) from <table> where <whatever>&quot; is much faster - for some reason I figured that's what the recordcount did automatically. Apparently, with server side cursors, it has to bring in the recordset and then count them instead which takes much, much too long for large recordsets. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top