Skip to content
Arthur van de Vondervoort edited this page Dec 14, 2024 · 2 revisions

Use Rec.IsEmpty() for checking record existence.

The Rec.Count() function can be an expensive operation, especially on large tables, as it performs a full table or index scan to count all records in the database. This can significantly degrade performance and unnecessarily load the database.

Instead of Rec.Count() to check for the presence of records, use the more efficient Rec.IsEmpty() function. Unlike Rec.Count(), Rec.IsEmpty() stops immediately after finding a single record, reducing database load and improving performance.

Checking for no records

if Rec.Count() = 0 then

Should be replaced by

if Rec.IsEmpty() then

Checking for any records

if Rec.Count() > 0 then

Should be replaced by

if not Rec.IsEmpty() then

Read more:

Clone this wiki locally