Product Logo

CNS Query

Query your databases without relationships.

Counting Rows

When you want to get a row count, it it is better to count the internal rowid field instead of * like so:

CNSQuery_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):

CNSQuery_ExecuteSQLEx(“MyFile”; “SELECT COUNT(1) FROM "MyTable"”; False)