Skip to content
Arthur van de Vondervoort edited this page Dec 19, 2024 · 3 revisions

Use Rec.Find('-') with Rec.Next() for checking exactly one record.

Using Rec.Count() to determine if a table has exactly one or more records can cause significant performance issues, especially on large tables, as it triggers a full table or index scan.

For a more efficient approach, use a combination of Rec.Find('-') and Rec.Next(). This method minimizes database load by stopping after finding the necessary records, for faster and more efficient record checks.

Checking for exactly one record

if Rec.Count() = 1 then

Should be replaced by

if Rec.Find('-') and (Rec.Next() = 0) then

Checking for more than one record

if Rec.Count() > 1 then

Should be replaced by

if Rec.Find('-') and (Rec.Next() <> 0) then

Read more:

Clone this wiki locally