11
Views
4
Comments
Solved
About appropriate record counting
Application Type
Traditional Web, Mobile, Reactive, Service

Hi Everyone

This best practice document said below.

"Don’t use the .Count property, in Aggregates or SQL queries, just to test if the query returned something or not. Testing <Query>.List.Empty instead of testing <Query>.Count = 0 "

I understand. But what about list length? Is Lenght=0 equals to Empty?

Kind regards,

mvp_badge
MVP
Solution

Hi Tom,

If you only need to test for existence of records, do not need to know how many there are, and do not need any of the data, then Empty with the “Max Records” of the Query set to 1 will be the most performant test.  

See for more information about Empty, Count and Length this great article from my fellow MVP Justin James:
https://itnext.io/which-property-to-see-if-a-query-has-results-9c51139084b5

Kind regards,

Daniel

Champion

Hi Daniël,

Thanks for the reply. Now I understand Length=0 also has an impact on performance.

Kind regards,

Hey Tom,

Maybe you can try looking at the explanation here:

Difference Between Current.Count and Length | OutSystems 


Thanks

Champion

Hi Angel,

Thanks for your reply. I understand the difference between Count and Length.

I just want to know When using Empty or Length=0 the performance is the same

Thanks

mvp_badge
MVP
Solution

Hi Tom,

If you only need to test for existence of records, do not need to know how many there are, and do not need any of the data, then Empty with the “Max Records” of the Query set to 1 will be the most performant test.  

See for more information about Empty, Count and Length this great article from my fellow MVP Justin James:
https://itnext.io/which-property-to-see-if-a-query-has-results-9c51139084b5

Kind regards,

Daniel

Champion

Hi Daniël,

Thanks for the reply. Now I understand Length=0 also has an impact on performance.

Kind regards,

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.