When there is an Integer Primary Key, rowid and the pk field name are synonyms for the same thing and behave identically.
Tom-----Original Message----- From: Peter Bezemek
Sent: Tuesday, December 11, 2012 12:10 PM To: yunqa@xxxxxxxxxxxxx Subject: [yunqa.de] Re: max(rowid) instead of Count(*) for large databases? If your table employs a dedicated primary key of integer type and you don't delete any rows, you can use SELECT MAX(your_pk) FROM MyTable That should be fast too and since the primary key is in your control, you can rely on it. Regards, Peter Bezemek On 11. 12. 2012 15:31, Delphi Inspiration wrote:
On 11.12.2012 08:43, email@xxxxxxxxxx wrote:I've been trying to optimize my application to work with rather large databases, and I accidentally realized that max(rowid) is way faster than Count(*) Assuming I don't delete records from database, is it safe to use this SQL statement? SELECT MAX(rowid) from MyTable instead of SELECT Count(*) from MyTable
_______________________________________________ Delphi Inspiration mailing list yunqa@xxxxxxxxxxxxx //www.freelists.org/list/yunqa _______________________________________________ Delphi Inspiration mailing list yunqa@xxxxxxxxxxxxx //www.freelists.org/list/yunqa