4 ms·
As the article notes, > Redundant conditions are nice because they require no changes to the database [...] This makes them useful for queries that are only so
by stux 3y ago
As the article notes,
> Redundant conditions are nice because they require no changes to the database [...] This makes them useful for queries that are only sometimes run or where indexes can't be easily added to the main conditions
but where possible I typically prefer adding an index on the expression that the query is using (if your database supports it) since it expresses your intent more clearly. A redundant condition is more likely to get "optimized away" by other developers or changes in the query planner.
- shrdlu2 3y agoYeah, I would think functional/function-based indexes should be mentioned. Add an index or add a redundant column? Almost all of time I would prefer the index. Of course if your database can't be changed then maybe you can use this trick if there is already a suitable indexed column.
- aarondf 3y agoYeah I could definitely add some links to or descriptions of functional indexes. If you're curious, here's a video I did on it: https://planetscale.com/courses/mysql-for-developers/indexes/functional-indexes https://planetscale.com/courses/mysql-for-developers/indexes...