I have a query in Microsoft Access, that needs c.a 6 seconds to return 1000 records.
SELECT DISTINCTROW tb_bauteile.*
FROM tb_bauteile
LEFT JOIN FehlerCodes_akt_Liste
ON tb_bauteile.CDT = FehlerCodes_akt_Liste.CDT
WHERE (( ( FehlerCodes_akt_Liste.Steuergerät ) = 'MEDC17' ))
ORDER BY FehlerCodes_akt_Liste.Fehlerpfad;
I put index on the neccessary fields.
tb_bauteile has c.a 3000 records and FehlerCodes_akt_Liste has c.a 20000 records. If I delete Where and order Clause the query returns the records very fast.
How can I optimize my query?
You have …
But then this
WHEREclause …That constraint makes the
LEFT JOINmoot … your result set will include only rows where you have matches betweentb_bauteile.CDTandFehlerCodes_akt_Liste.CDT. You may as well switch to anINNER JOINwhich should be faster.Here are some other issues to examine.
DISTINCTROW?CDT,Steuergerät, andFehlerpfad. Have you also performed a compact operation (which updates the statistics)?