Just a curiosity about which I can't find any discussion.
Any thoughts on which of the following two it is "generally" superior, if checking to see whether any records match a filter.
record.filter;
if not record.findfirst then
<do something>
record.filter;
if record.count > 0 then
<do something>
I would assume that for reasonably well-refined filters on tables with lots of fields that doing the count is faster than retrieving a record (less data being transferred), but I could imagine that for poorly defined filters, it might take more work to count all the records than to just retrieve the first hit (longer query on SQL Server).
Any "rules of thumb"?
0
Answers
RIS Plus, LLC
Rule of thumb:
"If you do NOT really care how many then do NOT use COUNT"
"If you only care if there are any then use ISEMPTY"
"If you only care if there are any AND you want to do something with the first record, then use FINDFIRST"