We have a SQL query that is doing a full table scan:
DELETE
FROM oc_cart
WHERE (api_id > ? OR customer_id = ?)
AND date_added < DATE_SUB(NOW(), INTERVAL ? HOUR)
Is it possible to create an index to optimize this query?
For now I have create 2 indices:
- one on date_added
- one on (date_added, customer_id and api_id)
But it seems that the query is still doing full scan.