3231
Views
4
Comments
Solved
Difference Between Current.Count and Length
Question

As mentioned in the title. Is there any difference between the following two queries?

1. Entity.List.Length

2. Entity.List.Current.Count

2019-09-24 18-41-25
Jorge Martins
 
MVP
Solution

Hi Stephen,

Consider a query GetUsers that fetches all records of Users that have their Is_Active attribute set to True.

  • GetUsers.List is the result set of your query. It's Length runtime property will hold the number of records in the list returned.
  • GetUsers.Count is the number of User records that match the filter.

When you access one of these two outputs of a query you will execute a query to the database, if you use the value of both, then two queries will execute: one to get the count, the other to get the requested records.

The answer to your question is "it depends":

  • If your query returns all records that have the Is_Active attribute set to True then there is no difference between the two values.
  • GetUsers.List.Length will have a different value from GetUsers.Count when:
    • The query has a Max. Records value (for instance 30), and there are more records in the database that match the filter (for instance, 231).
    • The query is bound to a Table Records on the Web Screen, there are more records in the database than the Table Records will display per page (Line Count property) and the Table Records is not displaying the last page.
2018-11-21 17-31-38
Priya Khade

Stephen Li wrote:

As mentioned in the title. Is there any difference between the following two queries?

1. Entity.List.Length

2. Entity.List.Current.Count


Hi,

Do you want to ask difference between Entity.List.Length and Entity.Count?

Well, when you have such queries you can assign this values to a variable and check.

Thanks

2019-09-24 18-41-25
Jorge Martins
 
MVP
Solution

Hi Stephen,

Consider a query GetUsers that fetches all records of Users that have their Is_Active attribute set to True.

  • GetUsers.List is the result set of your query. It's Length runtime property will hold the number of records in the list returned.
  • GetUsers.Count is the number of User records that match the filter.

When you access one of these two outputs of a query you will execute a query to the database, if you use the value of both, then two queries will execute: one to get the count, the other to get the requested records.

The answer to your question is "it depends":

  • If your query returns all records that have the Is_Active attribute set to True then there is no difference between the two values.
  • GetUsers.List.Length will have a different value from GetUsers.Count when:
    • The query has a Max. Records value (for instance 30), and there are more records in the database that match the filter (for instance, 231).
    • The query is bound to a Table Records on the Web Screen, there are more records in the database than the Table Records will display per page (Line Count property) and the Table Records is not displaying the last page.
2025-10-16 09-50-15
Yuri Fontes

If you are using pagination, generally the query is limited by the number of records you want to show on each screen.

If the number of records you want to show on the screen is 10, your length will be a maximum of 10. Let's assume that the query found 100 records that match the filters. In this case your count will be 100. In this first case the count and the length are different.


If the number of records in the table, respecting the filters, is 10, and the number of records per page is 10, then count and length are the same.


If you are using aggregate, the length is limited by the Max Record, and the count will only look at the filters.


UserImage.jpg
Waleed Khan

Hi Community,

Founded this question & comments on it very useful.

Adding little more detail to this thread as I was getting <List>.Count returned with (Not evaluated) value. <List>.Length or <List>.Count generated from an aggregate only gets value if it's been used further. 

For e.g. <List>.Length generated from an aggregate will have a value if its been further used by some action ListAppendAll or other. Similarly, <List>.Count will have value if its been used in expression on Web Screen or other.

This is due to optimization done by OutSystem. Helpful article to understand query optimization - https://success.outsystems.com/documentation/11/monitoring_and_troubleshooting_apps/manage_technical_debt/code_analysis_patterns/appropriate_record_counting/

How it works can be referred to Solution - https://www.outsystems.com/forums/discussion/43057/difference-between-current-count-and-length/#Post155333

Note: Above was tested in Tradition Web Application with debugger.


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