DB unnecessary ordering
Kulda22 opened this issue · 1 comments
Kulda22 commented
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 commented
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!