perf(core-api): Use a faster alternative to derive an estimate#1655
perf(core-api): Use a faster alternative to derive an estimate#1655faustbrian merged 6 commits intodevelopfrom
Conversation
|
I would look at https://wiki.postgresql.org/wiki/Count_estimate and create a function via migration to then wrap queries in it to get the proper estimate that is based on the full query with all conditions. |
That would be one solution. However in some cases we can derive the exact result very fast and thus don't need to bother with estimates. One such is: So, I am looking into how to do that. |
2f1fea8 to
5af85e9
Compare
When we use OFFSET and LIMIT in SQL we want to assess the total number of rows that would have been returned if OFFSET and LIMIT were omitted. Instead of doing a separate query with COUNT(*), parse the output of EXPLAIN SELECT ... and fetch the number of rows from there.
5af85e9 to
366212b
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1655 +/- ##
===========================================
+ Coverage 39.41% 39.46% +0.04%
===========================================
Files 353 353
Lines 7674 7672 -2
Branches 1076 1102 +26
===========================================
+ Hits 3025 3028 +3
+ Misses 4635 4627 -8
- Partials 14 17 +3
Continue to review full report at Codecov.
|
| expect(response.data.data).toBeArray() | ||
|
|
||
| expect(response.data.data).toHaveLength(100) | ||
| expect(response.data.meta.totalCount).toBe(153) |
There was a problem hiding this comment.
Notice: that count is supposed to be an estimate. So we may return 100 rows, totalCount=100, but however there may be e.g. 110 rows in the database.
|
@vasild This can now be adjusted to TypeScript on the |
faustbrian
left a comment
There was a problem hiding this comment.
Looks good once the conflicts are resolved.
Proposed changes
Types of changes
Checklist