database - Setting index in MySql on a Varchar Column -
In MySQL, I have a UNION query which takes a long time to execute. The query looks
(date id from date, x, y, date from date (select min (date) from table WHERE flag = 0 and id = = and between date? And? ) And id =? And flag = 0 Order ID from DESC limit 1) Union (select ID, X, Y, date from date to date (selectable MAX (date) from table where flag = 0 and id =? And between date ? And?) And id =? And flag = 0 ID command by DESC limit 1)
The question above Received the best performance, which is required to index the C column and why?
id - type full date - type datetime flag - type tinyint (4)
I have indexed the following 1. ID 2. Date 3. Flag
Comments
Post a Comment