Consider there are 2M records in both shipment and order table.
SELECT DISTINCT
s0_.id AS id0,
s0_.updated_at AS updated_at1
FROM
`shipment` s0_
LEFT JOIN `order` s1_ ON s0_.order_id = s1_.id -- These line
LEFT JOIN `address` s2_ ON s1_.shipping_address_id = s2_.id -- These line
ORDER BY s0_.updated_at DESC
LIMIT 20 OFFSET 0
If I remove the left join MariaDB will use the index specified, why? Is there any solution?
This SQL is generated by a library and I have limited options to fix it.
This SQL is generated by a library and I have limited options to fix it.
This SQL is generated by a library and I have limited options to fix it.
This SQL is generated by a library and I have limited options to fix it.
This SQL is generated by a library and I have limited options to fix it.
Don't ask me to remove it. I know it has no use. And I think query optimizer need to think so too as it is just LEFT JOIN.
I am using MariaDB 10.1
EXPLAIN {query}andSHOW CREATE TABLE shipmentandSHOW CREATE TABLE ordersto see what indexes you have.LEFT JOINs as a bug in the Pagerfanta library :-) Take responsibility for the code you use.