Asked by:
my query takes a long time to run ,why?

Question
-
I have a query that returns c.a 1800 records( not many) but It takes long time to ran (10 seconds) but I can not understand why? this is my query that takes a long time:
SELECT tb_KonzeptFunktionen.Konzept AS KonzeptID, tb_KonzeptFunktionen.Funktion, tb_KonzeptFunktionen.Version, qryFunktionen_Übersicht.ID, qryFunktionen_Übersicht.Fehlerpfad_Kommentar AS Kommentar, qryFunktionen_Übersicht.Fehlerpfadname, qryFunktionen_Übersicht.Fehlerpfad_CDT, qryFunktionen_Übersicht.Fehlerpfad_Kommentar, qryFunktionen_Übersicht.symptombasiert, qryFunktionen_Übersicht.Beschreibung_vorhanden, qryFunktionen_Übersicht.Max_Pfad, qryFunktionen_Übersicht.Max_Info, qryFunktionen_Übersicht.Max_Status, qryFunktionen_Übersicht.Max_Strategie, qryFunktionen_Übersicht.Max_Prüfplan, qryFunktionen_Übersicht.Min_Pfad, qryFunktionen_Übersicht.Min_Info, qryFunktionen_Übersicht.Min_Status, qryFunktionen_Übersicht.Min_Strategie, qryFunktionen_Übersicht.Min_Prüfplan, qryFunktionen_Übersicht.Sig_Pfad, qryFunktionen_Übersicht.Sig_Info, qryFunktionen_Übersicht.Sig_Status, qryFunktionen_Übersicht.Sig_Strategie, qryFunktionen_Übersicht.Sig_Prüfplan, qryFunktionen_Übersicht.Plaus_Pfad, qryFunktionen_Übersicht.Plaus_Info, qryFunktionen_Übersicht.Plaus_Status, qryFunktionen_Übersicht.Plaus_Strategie, qryFunktionen_Übersicht.Plaus_Prüfplan, qryFunktionen_Übersicht.Beschreibung_allgemein, qryFunktionen_Übersicht.Funktionsname FROM tb_KonzeptFunktionen RIGHT JOIN qryFunktionen_Übersicht ON tb_KonzeptFunktionen.Funktion = qryFunktionen_Übersicht.Funktionsname WHERE (((tb_KonzeptFunktionen.Konzept)=[Formulare]![frm_Fahrzeug]![ID]))
SELECT tbFunktionen_Übersicht.*,
tbFunktionen.Funktionsname,tbFunktionen.Funktionsbeschreibung,
tbFunktionen.diagnoserelevant,
tbFunktionen.ID AS FunktionsID
FROM tbFunktionen_Übersicht
INNER JOIN tbFunktionen ON tbFunktionen_Übersicht.Funktion = tbFunktionen.ID
ORDER BY tbFunktionen.Funktionsname, tbFunktionen_Übersicht.Fehlerpfadnameand
aove query is another query related to first query
I added an index to the fields that appear in ORDER oder JOINS but no effect Would you please help me if possible?
- Edited by babak.per Wednesday, May 23, 2012 8:21 AM ad format
Wednesday, May 23, 2012 8:16 AM
All replies
-
Hi,
the second query is qryFunktionen_Übersicht, right? You can remove ORDER BY clause. Sorting may take a good part of query execution time. Does it make difference?
Andrey V Artemyev | Saint-Petersburg, Russia
Russian blog artemyev.biztoolbox.ruWednesday, May 23, 2012 8:45 AM -
Hi Andrev
yes it is riht ,the second one is qryFunktion_Übersicht.
I removed ORDER BY but no change
Wednesday, May 23, 2012 9:04 AM -
I would start by getting some metrics on each query.
How many records are in tb_KonzeptFunktionen, tbFunktionen_Übersicht and tbFunktionen?
How long does it take qryFunktionen_Übersicht by itself to run?
How long does the query take to run if you remove the right join to qryFunktionen_Übersicht from the first query?
Wednesday, May 23, 2012 10:14 PM -
Hi Ray,
Thank you for your answer.
qryFunktionen_Übersicht runs in a scenod or less. If I removed WHERE Clauase in first query it gives me ca 80000 records in a second but with a WHERE clause 10 seconds
Thursday, May 24, 2012 2:50 PM -
Probably a couple of shots in the dark.
Why not use tb_KonzeptFunktionen.KonzeptID instead of tb_KonzeptFunktionen.Konzept in the WHERE statement?
Maybe pass the [Formulare]![frm_Fahrzeug]![ID] as a parameter. Maybe looking up the control value is slowing it down.HTH
Thursday, May 24, 2012 4:25 PM -
Thank you Imran
I didnot understand what do you exactly mean. It depand on Logic of my programm and I cant use KonzeptID instead of tb_KonzeptFunktionen.Konzept. I think you are right but how can I solve this problem?(Pass the [Formulare]![frm_Fahrzeug]![ID] as a parammeter) .
@Ray: I can answer you now more precise:
tb_KonzeptFunktionen has c.a 51500 records
tbFunktionen_Übersicht has 5000 records
tbFunktionen has 1500 records
qryFunktionen_Übersicht less than a second to run
Tuesday, May 29, 2012 7:07 AM -
babak.per has asked a related question here:
How can I explain the cause of a phenomenon in my query in access?
http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/8193aa29-9835-48a9-ae1c-512e95b15304
Matthew Slyman M.A. (Camb.)
Tuesday, May 29, 2012 4:23 PM