so I want a record count from a query with more than 100 rows.
I have been using the get object count block
but this does not have a having clause option. my query looks like this:
so the maximum number of rows I can return at one time is 100 and I know I have more than 100 rows.
this is my current solution.
Is there a better way to do this? this seems really inefficient as I only need the record count ( because I’m only going to return the first 100 rows to the user but I want to let them know there is more data ) so first 100 rows of XXX records shown is what I’m trying to do but this has me walking through all 303 (or whatever) to get the count even though I only want to get data on the first 100.
thanks,
H
Hello @hharrington,
I studied your problem, unfortunately at the moment it is impossible to get the number of records using your query (using the Get Object Count API). This will be possible in the future when we move to a new version of the database, however I can’t give you any timeline for when that will be.
But your approach is working and can be optimized.
Here is what I can suggest for you:
- Load the first set of objects using pageSize 100 and offset 0.
- If less than 100 objects were returned in the first step, skip the next steps - obviously, there are no more than 100 objects.
Otherwise, if you got 100 objects, load another set of objects (without any While loops), but this time set the offset to 100 and pageSize to 1.
- If the second step returned a non-empty array, then you can just tell the user that he has more data (without specifying exactly how much - I think it will be enough for them just to know that there is more data).
Otherwise, if an empty array is returned, then there is no more data and you have loaded everything that matched the given query.
Hope it helps.
Regards,
Stanislaw
Oh wow that’s a huge improvement over my code! Thanks!
I’ll look forward to the new db roll out though.
Thanks again!
H
1 Like