Alloy Collection pagination using limit and offset
0 reputation · 02 Aug 2022, 23:53 UTC
Alloy Collection Dataset Management
The Titanium SDK Alloy Collections ORM allows for record retrieval using the fetch() method. When dealing with large datasets, developers typically use limit and offset to paginate results and prevent memory exhaustion on the device.
While fetch({limit: n}) handles the initial set, subsequent pages require manual offset tracking because the ORM does not provide a native page cursor. This approach relies on the underlying SQLite LIMIT and OFFSET clauses, which may encounter performance degradation as the offset value increases in very large tables.
Additionally, there is no integrated method within a single fetch call to retrieve the total count of matching records for the purpose of calculating total pages.
- What is the recommended strategy for implementing keyset pagination in Alloy to avoid the performance overhead of high offset values?
- Is there a documented way to retrieve the total record count without performing a full fetch of the dataset?