Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance regression in v0.8.0 #51

Open
avatarneil opened this issue Apr 14, 2022 · 1 comment
Open

Performance regression in v0.8.0 #51

avatarneil opened this issue Apr 14, 2022 · 1 comment

Comments

@avatarneil
Copy link

Hello!

I'm a maintainer on a project https://github.com/lacuna-tech/mds-core which utilizes this library, and first off would like to thank you for putting this together! It definitely makes pagination with TypeORM much easier :)

Recently, we upgraded to v0.8.1 of this library, and discovered a performance regression when paginating on keys that are not the unique key. I believe that this regression occurred in this commit (which went into v0.8.0). The PG query planner (in our case, we are running against Postgres 13.4 running in RDS Aurora) seems to handle WHERE someColumn>someValue OR someColumn=someValue very poorly; we were seeing some queries which used to take 2s take >8min to return. One minor hand-made change to our queries, however, had them returning very quickly again: WHERE someColumn>=someValue.

I think that there is a pretty trivial change to the paginator that would fix this:

qb.where(`${this.alias}.${key} ${operator} ${this.paginationUniqueKey !== key ? '=' : ''}:${key}_1`, paramsHolder);

If you think this approach makes sense, I'm happy to cut a PR!

@benjamin658
Copy link
Owner

Hi @avatarneil,

My apologies for the late reply.

The 3d2c20f changes resulted in a slow query, which is difficult to detect from the current test cases. I appreciate you doing some hand-made changes and recognizing the issue.

The PR is always welcome, thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants