<- Back to list
Counting Rows
How to get a row count using rowid instead of costly COUNT(*)
When you want to get a row count, it it is better to count the internal rowid field instead of * like so:
MMQuery_ExecuteSQLEx("MyFile"; "SELECT COUNT(rowid) FROM \"MyTable\""; False)
Trying to do a count of all the fields, using *, is expensive for tables with large sets of fields and/or data. The rowid field is FileMaker's internal Record ID (same value as Get(RecordID)) and will always be there in any table.
An alternate way is to use COUNT(1):
MMQuery_ExecuteSQLEx("MyFile"; "SELECT COUNT(1) FROM \"MyTable\""; False)