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

DB unnecessary ordering #2

Open
Kulda22 opened this issue Feb 8, 2022 · 1 comment
Open

DB unnecessary ordering #2

Kulda22 opened this issue Feb 8, 2022 · 1 comment

Comments

@Kulda22
Copy link

Kulda22 commented Feb 8, 2022

Hi, I've noticed this SQL SELECT * FROM items ORDER BY RANDOM() LIMIT 1 in your database.

What it does, as far as I know, is it orders WHOLE database in some random way, then selects first element. This is really slow way of fetching one random row.

Faster way of doing this is generating random number (between 0 and table size) and then doing something like SELECT * FROM items WHERE ID = <generated number>". (It seems you don't have ID column, but column Unnamed: 0 looks like ID-like column, so making it primary key is a good idea)

@MariiaSizova
Copy link
Owner

Hey, thanks for your reply!
Yes I agree that it's not the most efficient way to do it!
Will fix this in the next update and close the issue.
Cheers!

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