This is a generic solution that works for all databases: SELECT. The alternative is to use an explicit range condition. However the solution from above does not apply to MySQL prior to version 5.7, because MySQL didn’t support function-based indexing before that version. The query uses a date format that only contains year and month: again, this is an absolutely correct query that has the same problem as before. The problem also occurs with databases that have a pure date type if you search for a longer period as shown in the following MySQL query: SELECT. If you use it inconsistently-sometimes with, sometimes without TRUNC-then you need two indexes! CREATE INDEX index_nameīut then you must always use TRUNC(sale_date) in the where clause. There is a rather simple solution for this problem: a function-based index. I make my living from SQL training, SQL tuning and consulting and my book “SQL Performance Explained”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |