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

ny_times_us_counties needs a "date desc" index #27

Closed
simonw opened this issue May 29, 2021 · 3 comments
Closed

ny_times_us_counties needs a "date desc" index #27

simonw opened this issue May 29, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented May 29, 2021

When you paginate through the https://covid-19.datasettes.com/covid/ny_times_us_counties table - which now has more than 1.3m records - each page takes ~200ms to query. It's sorted by date, descending with an index on date.

With an index on date desc instead each page only takes ~10ms.

@simonw simonw added the enhancement New feature or request label May 29, 2021
simonw added a commit that referenced this issue May 29, 2021
simonw added a commit that referenced this issue May 29, 2021
@simonw
Copy link
Owner Author

simonw commented May 29, 2021

Before deploying this change, https://covid-19.datasettes.com/covid?sql=select+*+from+pragma_index_xinfo%28%27idx_ny_times_us_counties_date%27%29 returns:

seqno cid name desc coll key
0 0 date 0 BINARY 1
1 -1   0 BINARY 0

@simonw
Copy link
Owner Author

simonw commented May 29, 2021

And now:

seqno cid name desc coll key
0 0 date 1 BINARY 1
1 -1 0 BINARY 0

@simonw
Copy link
Owner Author

simonw commented May 29, 2021

Turns out that wasn't the cause of the performance problem after all! simonw/datasette#1349

@simonw simonw closed this as completed May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant