Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
ingaponteca
330
Views
2
Comments
table record list.length vs table record count
Question
Training
OutSystems Widgets
I know that tablerecord.count perform a query to the database to get the count of records, but If I already executed a query will not be better to use query.list.length property to get the count?
Also, I am asking this, because in List_Navigation widget you use the query.count as the count of records instead the tablerecord.list.length and I am confussing because tablerecord.list.length can be lower or greater than query.count if the database change fast. Why do not use tablerecord.list.length in list_navigation instead?
Paulo Ramos
Staff
Hi Carlos,
The Platform tries to optimize this pattern by opening a cursor and retrieving rows in chunks as they are needed (instead of retrieving everything in one shot). The reason is performance - for example, if you have 100 000 rows in the table, but want to display only the first 50, this avoids all this data being transfered between the database and the front-end.
However, if you use the
Length
property, you are turning off this optimization. The Platform will need to retrieve all the data from the database in order to know the size of the list. So, yes, there is a trade-off here:
Count property: a second DB statement is executed
Length: all the rows are returned in one shot
ingaponteca
ok. Understood. So, is better to use count and do not pay the full extraction of data.
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...