usgo / agagd

American Go Association Games Database (AGAGD)
https://agagd.usgo.org
MIT License
47 stars 30 forks source link

Slow Queries for Pagination with Using Limit / Offset in Large Sets #182

Open michaelhiiva opened 3 years ago

michaelhiiva commented 3 years ago

Summary of the Bug

@duckpunch https://github.com/usgo/agagd/pull/180#discussion_r615553918

What's the rough size of the largest thing we'll pass in? LIMIT/OFFSET can be pretty slow, right?

Specifically the issue with performing large queries on large sets. https://docs.djangoproject.com/en/3.2/ref/paginator/#django.core.paginator.Paginator.object_list

If you’re using a QuerySet with a very large number of items, requesting high page numbers might be slow on some databases, because the resulting LIMIT/OFFSET query needs to count the number of OFFSET records which takes longer as the page number gets higher.

Notes