Comment by lovasoa
13 days ago
Optimizing out static expressions can be done in linear time at best. So if the number of clauses in WHERE is huge and the size of the underlying table is tiny (such as in the examples shown in the article we are commenting on), it will be better not to run the optimization.
But of course, in normal life, outside of the world of people having fun with Homomorphisms, queries are much smaller than databases.
Parsing the expression in the first place is already linear time.
True, but that doesn't mean doing additional work during the parse is free. Optimizing out static expressions will take additional time, and in general that additional time will be linear in the query size.
My argument is that, on average, it will more than pay for itself.
The only losing case, if there are any measurable ones, is where you have long queries and short data. I'd call that a case of "doing it wrong". Wrong tool for the job.