The mysql query I am working on is as follow:
select line_item_product_code, line_item_usage_start_date, sum(line_item_unblended_cost) as sum
from test_indexing
force index(date)
where line_item_product_code in('AmazonEC2', 'AmazonRDS')
and product_region='us-east-1'
and line_item_usage_start_date between date('2019-08-01')
and date('2019-08-31 00:00:00')
group by line_item_product_code, line_item_usage_start_date
order by sum;
I have applied indexing on the column("line_item_usage_start_date") but on running the query the indexing does not work and on explain the type is "ALL" and key is not being used. Indexing is not working only when where clause takes an "OR" or "IN" operator. The data types of columns are: line_item_product_code : TEXT line_item_unblended_cost : DOUBLE product_region : TEXT line_item_usage_start_date : TIMESTAMP My main objective for this query is : Optimizing query for fast response in the dashboard, I have this table of 192 columns and 9m+ rows with a csv size of 13+ GB. I guess indexing will solve my problem dealing with this query. Is there a alternative of these operators or any other solution for this?