←back to thread

128 points xlinux | 1 comments | | HN request time: 0s | source
Show context
lovasoa ◴[] No.42197498[source]
The topic of huge queries on tiny databases makes me think of this recent discussion on the SQLite forum: https://sqlite.org/forum/forumpost/0d18320369

Someone had an issue because SQLite failed to optimize the following query

    select * from t where x = 'x' or '' = 'x'
Someone said that SQLite could not optimize out the "or '' = 'x'" because it would be too expensive to compute. Which is obviously true only for huge queries on tiny datasets.
replies(3): >>42197594 #>>42197614 #>>42198312 #
hinkley ◴[] No.42197594[source]
Why would it be too expensive to optimize out static subexpressions?
replies(1): >>42198445 #
1. jjice ◴[] No.42198445[source]
My guess is that the expense can be tricky to calculate since the additional optimization prior to executing the query may take longer than if the query was just able to run (depending on the dataset, of course). I wonder if it's too expensive to calculate a heuristic as well, so it just allows it to execute.

Just a guess.