Board index » off-topic » Table1.recordcount
John Donaldson
Delphi Developer |
John Donaldson
Delphi Developer |
Table1.recordcount2006-01-20 08:58:10 PM off-topic0 We are using Table1.recordcount to determine the number of records in a dBase Table. large files take longer to execute the first time the recordcount is executed. In file size>a million records it can take over 10 seconds. Is there a faster way to get the total records of large dBase files? We are using D6 & IP3000. Thanks, John Donaldson |
Bill Todd
Delphi Developer |
2006-01-20 09:31:00 PM
Re:Table1.recordcount
John Donaldson wrote:
QuoteIs there a faster way to get the total records of large dBase files? which store the record count in the table header. The best solution is to not use the record count. -- Bill Todd (TeamB) |
Mike Shkolnik
Delphi Developer |
2006-01-20 10:12:59 PM
Re:Table1.recordcount
Execute the query:
with TQuery.Create(nil) do try SQL.Text := 'SELECT COUNT(*) FROM ' + yourTableName; DatabaseName := yourTTable.DatabaseName; Alias := yourTTable.Alias; Open; yourRecordCount := Fields[0].AsInteger finally Free end; PS: to get the record count in TTable, the dataset must fetch (load) all records to client cache and for large tables it takes a time. "John Donaldson" < XXXX@XXXXX.COM >wrote in message Quote
10 seconds. QuoteIs there a faster way to get the total records of large dBase files? We {smallsort} |
John Donaldson
Delphi Developer |
2006-01-20 11:04:48 PM
Re:Table1.recordcount
Mike,
Tried this approach and compared to Ttable which is exactly the same amount of time. The bde must be using sql... Thanks, John "Mike Shkolnik" < XXXX@XXXXX.COM >wrote: QuoteExecute the query: |
John Herbster
Delphi Developer |
2006-01-21 12:30:59 AM
Re:Table1.recordcount
"John Donaldson" < XXXX@XXXXX.COM >wrote in message
Quote
other information each record must be scanned for these flags. Is there any way that you can keep your own separate record count? --JohnH |
Daniele Barbato
Delphi Developer |
2006-01-22 03:00:35 AM
Re:Table1.recordcountQuote>"John Donaldson" < XXXX@XXXXX.COM >wrote in message |
Daniele Barbato
Delphi Developer |
2006-01-22 03:01:52 AM
Re:Table1.recordcount
"John Herbster" <herb-sci1_at_sbcglobal.net>ha scritto nel messaggio
Quote
daniele |
Mike Thrapp
Delphi Developer |
2006-03-17 11:52:52 PM
Re:Table1.recordcount
John,
If you are using Dbase or Paradox (maybe Foxpro), you can use the following procedure. It is not 100% accurate, but if you just need an approximate count, it is OK. DbiGetExactRecordCount loops through all the records. DbiGetRecordCount just takes the count from the table header, but if the deleted records are not purged (via a pack), they will still be included in the count. Mike Thrapp {======================================================================} Function GetRecordCount(Table : TTable) : LongInt; begin try DbiGetRecordCount(Table.Handle, Result); except DbiGetExactRecordCount(Table.Handle, Result); end; end; {GetRecordCount} "John Donaldson" < XXXX@XXXXX.COM >wrote in message Quote
|
Bill Todd
Delphi Developer |
2006-03-17 11:52:53 PM
Re:Table1.recordcount
Mike Thrapp wrote:
Quotebut if the deleted records are not purged (via a pack), they will -- Bill Todd (TeamB) |