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

Improve search performance #129

Closed
imnotteixeira opened this issue Mar 4, 2021 · 3 comments · Fixed by #212
Closed

Improve search performance #129

imnotteixeira opened this issue Mar 4, 2021 · 3 comments · Fixed by #212
Assignees
Labels
P1 Medium Priority
Milestone

Comments

@imnotteixeira
Copy link
Collaborator

Currently, searching many offers depends on a offset + limit combination to simulate pagination of results. This can be slow and we might lose results in the event of addition/removal of elements in between page changes.

I propose the change to keyset-based search.
To the one implementing this, please read this article, which explains it very well: https://medium.com/swlh/mongodb-pagination-fast-consistent-ece2a97070f3

The basic idea is to take advantage of object ids being naturally sorted, so we can use the value of the last returned object as the threshold to fetch the next page (next page will have elements whose IDs will be > than the last element from previous page)

@imnotteixeira imnotteixeira added the P1 Medium Priority label Mar 4, 2021
@imnotteixeira imnotteixeira added this to the MVP milestone Mar 4, 2021
@miguelpduarte
Copy link
Collaborator

By using the keyset method, we lose the ability to randomly access the pages. Simply saying, we actually can’t get page 3 without getting page 2 and getting page 2 without getting page 1. But the good thing is we don’t really care about that in most applications.

This bothers me a bit. Is the performance that terrible?

@miguelpduarte
Copy link
Collaborator

I would even dare to say: Since the data we send in each response is not all that large, we could even consider having a larger "window" in the back-end and paginate that in the front-end. May increase implementation complexity in the front-end but may help with potential performance issues if that was the core focus.

Since it seems to only be a problem after several tens of pages and our goal is to have a lot of filtering possibilities, I don't see us reaching that level of active offers quickly enough to justify losing the possibility of random page access, I think.

@imnotteixeira
Copy link
Collaborator Author

Nothing in this issue is really relevant at our level. However, I have found that in NoSQL databases, having that offset+limit pattern is not the way to go, hence the creation of this issue. It's kind of a learning opportunity if someone wants it.

Additionally, regarding the "cannot jump to page x" problem. That is not a concern in this scenario since that is not a use case of the application. We use "infinite scroll", so we'll load continuously

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

Successfully merging a pull request may close this issue.

4 participants