Subject | Re: Slow execution of first query |
---|---|
Author | Nico Callewaert |
Post date | 2005-11-25T08:47:01Z |
Hi Pavel,
For sure this is something to do with caching, because once the query
is ONE time executed, it doesn't matter in the application or
IBExpert, everything is running fast. There are a few triggers and
lots of stored procedures referencing this table (CSFDPX).
Here is the query and execution plan :
SELECT
FH.FH_UNIEK,
FH.FH_SLOT,
FH.FH_CODE,
FH.FH_OLDCODE,
FH.FH_BONNR,
FH.FH_FAKNR,
FH.FH_KLNR,
FH.FH_BVW,
FH.FH_AGT,
FH.FH_VDAT,
FH.FH_BONDAT,
FH.FH_KORT,
FH.FH_VOORS,
FH.FH_LEVNM,
FH.FH_BTWEX,
FH.FH_REF1,
FH.FH_REF2,
FH.FH_REF3,
FH.FH_STATUS,
FH.FH_PROJ,
FH.FH_EXT1,
FH.FH_MNT,
FH.FH_KOERS,
FH.FH_CONTAN,
FH.FH_LEVADRES,
FH.FH_LEVSTR,
FH.FH_LEVPLAATS,
FH.FH_LEVLND,
FH.FH_KORTING,
FH.FH_LEVSTR2,
FH.FH_STR3,
FH.FH_TAV,
FH.FH_TAVFAX,
FH.FH_TAVTEL,
FH.FH_TAVEMAIL,
FH.FH_VORD,
FH.FH_VERHUUR,
FH.FH_VERHUUREVENVANDAT,
FH.FH_VERHUUREVENTOTDAT,
FH.FH_VERHUURBLOKVANDAT,
FH.FH_VERHUURBLOKTOTDAT,
FH.FH_VERHUURPERIODE,
FH.FH_SUBPROJ,
FH.FH_AFD,
FH.FH_MEDE,
FH.FH_DEBLINK,
FH.FH_UITV,
FH.FH_SEL,
FH.FH_VOOR,
FH.FH_CRDAT,
FH.FH_BHLINK,
FH.FH_AFGEWERKT,
FH.FH_TEKST,
FH.FH_TEKST2,
FH.FH_TEKSTV,
FH.FH_WEEKLEV,
FH.FH_AANSPREKING,
FH.FH_CONTACTPERSOON,
FH.FH_REFERENTIE,
FH.FH_ALU,
FH.FH_RVS,
FH.FH_ZINCOR,
FH.FH_STAAL,
FH.FH_TRANSPORTEUR,
FH.FH_KARTON,
FH.FH_GEWICHT,
FH.FH_COLIS,
FH.FH_EUROPALET,
FH.FH_OPZET,
FH.FH_PALET1,
FH.FH_PALET2,
FH.FH_PALET3,
FH.FH_TRANSTYPE,
FH.FH_CONTROLE,
FH.FH_VERPAKKING,
FH.FH_FOLIE,
FH.FH_WEDERVERKOPER,
FH.FH_PNID,
FH.FH_FAKDAT,
FH.FH_KORTKLANT,
FH.FH_INFO,
FH.FH_DATAFH,
FH.FH_INTRASTAT,
FH.FH_KILOM,
FH.FH_PLAAT,
FH.FH_AUTO,
KL.KL_COD,
KL.KL_NAM,
KL.KL_STR,
KL.KL_WPL,
KL.KL_MNT,
KL.KL_SRT,
KL.KL_T,
KL.KL_TEL,
KL.KL_FAX,
KL.KL_EMAIL,
KL.KL_BOE,
KL.KL_PRIJS_OPP,
KL.KL_SLECHTBET,
KL.KL_KLANT_NIEUW,
PR.PR_NR,
PR.PR_KROM,
PR.PR_STDAT,
PR.PR_ENDDAT,
SU.SU_SUB,
SU.SU_OMS,
VE.VE_OMS,
WE.WE_EMAIL,
TR.TR_EMAIL
FROM CSFHPX FH
LEFT OUTER JOIN KLPX KL ON KL.KL_COD = FH.FH_KLNR
LEFT OUTER JOIN PROJPX PR ON PR.PR_NR = FH.FH_PROJ
LEFT OUTER JOIN SUBPROJ SU ON (SU.SU_NR = FH.FH_PROJ) AND (SU.SU_SUB
= FH.FH_SUBPROJ)
LEFT OUTER JOIN VERTEW VE ON VE.VE_COD = FH.FH_AGT
LEFT OUTER JOIN TRANSPORTEUR TR ON TR.TR_CODE = FH.FH_TRANSPORTEUR
LEFT OUTER JOIN WEDERVERKOPERS WE ON WE.WE_COD = FH.FH_WEDERVERKOPER
WHERE (FH.FH_CODE = 'B')
Plan
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (FH INDEX (FH_CODE_INDEX),KL
INDEX (RDB$PRIMARY36)),PR INDEX (RDB$PRIMARY55)),SU NATURAL),VE INDEX
(RDB$PRIMARY76)),TR INDEX (RDB$PRIMARY167)),WE INDEX (RDB$PRIMARY292))
Adapted Plan
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (FH INDEX (FH_CODE_INDEX),KL
INDEX (INTEG_96)),PR INDEX (INTEG_142)),SU NATURAL),VE INDEX
(INTEG_205)),TR INDEX (INTEG_369)),WE INDEX (INTEG_703))
Many thanks !
Best regards,
Nico
> That's one more sign that what you see is a server-side caching. Ifand
> you could post your query, definition script for related metadata
> the query execution plan, then probably people in this list couldhelp
> you with the query improvement (if the improvement is possible atThanks again for your reply !
> all).
For sure this is something to do with caching, because once the query
is ONE time executed, it doesn't matter in the application or
IBExpert, everything is running fast. There are a few triggers and
lots of stored procedures referencing this table (CSFDPX).
Here is the query and execution plan :
SELECT
FH.FH_UNIEK,
FH.FH_SLOT,
FH.FH_CODE,
FH.FH_OLDCODE,
FH.FH_BONNR,
FH.FH_FAKNR,
FH.FH_KLNR,
FH.FH_BVW,
FH.FH_AGT,
FH.FH_VDAT,
FH.FH_BONDAT,
FH.FH_KORT,
FH.FH_VOORS,
FH.FH_LEVNM,
FH.FH_BTWEX,
FH.FH_REF1,
FH.FH_REF2,
FH.FH_REF3,
FH.FH_STATUS,
FH.FH_PROJ,
FH.FH_EXT1,
FH.FH_MNT,
FH.FH_KOERS,
FH.FH_CONTAN,
FH.FH_LEVADRES,
FH.FH_LEVSTR,
FH.FH_LEVPLAATS,
FH.FH_LEVLND,
FH.FH_KORTING,
FH.FH_LEVSTR2,
FH.FH_STR3,
FH.FH_TAV,
FH.FH_TAVFAX,
FH.FH_TAVTEL,
FH.FH_TAVEMAIL,
FH.FH_VORD,
FH.FH_VERHUUR,
FH.FH_VERHUUREVENVANDAT,
FH.FH_VERHUUREVENTOTDAT,
FH.FH_VERHUURBLOKVANDAT,
FH.FH_VERHUURBLOKTOTDAT,
FH.FH_VERHUURPERIODE,
FH.FH_SUBPROJ,
FH.FH_AFD,
FH.FH_MEDE,
FH.FH_DEBLINK,
FH.FH_UITV,
FH.FH_SEL,
FH.FH_VOOR,
FH.FH_CRDAT,
FH.FH_BHLINK,
FH.FH_AFGEWERKT,
FH.FH_TEKST,
FH.FH_TEKST2,
FH.FH_TEKSTV,
FH.FH_WEEKLEV,
FH.FH_AANSPREKING,
FH.FH_CONTACTPERSOON,
FH.FH_REFERENTIE,
FH.FH_ALU,
FH.FH_RVS,
FH.FH_ZINCOR,
FH.FH_STAAL,
FH.FH_TRANSPORTEUR,
FH.FH_KARTON,
FH.FH_GEWICHT,
FH.FH_COLIS,
FH.FH_EUROPALET,
FH.FH_OPZET,
FH.FH_PALET1,
FH.FH_PALET2,
FH.FH_PALET3,
FH.FH_TRANSTYPE,
FH.FH_CONTROLE,
FH.FH_VERPAKKING,
FH.FH_FOLIE,
FH.FH_WEDERVERKOPER,
FH.FH_PNID,
FH.FH_FAKDAT,
FH.FH_KORTKLANT,
FH.FH_INFO,
FH.FH_DATAFH,
FH.FH_INTRASTAT,
FH.FH_KILOM,
FH.FH_PLAAT,
FH.FH_AUTO,
KL.KL_COD,
KL.KL_NAM,
KL.KL_STR,
KL.KL_WPL,
KL.KL_MNT,
KL.KL_SRT,
KL.KL_T,
KL.KL_TEL,
KL.KL_FAX,
KL.KL_EMAIL,
KL.KL_BOE,
KL.KL_PRIJS_OPP,
KL.KL_SLECHTBET,
KL.KL_KLANT_NIEUW,
PR.PR_NR,
PR.PR_KROM,
PR.PR_STDAT,
PR.PR_ENDDAT,
SU.SU_SUB,
SU.SU_OMS,
VE.VE_OMS,
WE.WE_EMAIL,
TR.TR_EMAIL
FROM CSFHPX FH
LEFT OUTER JOIN KLPX KL ON KL.KL_COD = FH.FH_KLNR
LEFT OUTER JOIN PROJPX PR ON PR.PR_NR = FH.FH_PROJ
LEFT OUTER JOIN SUBPROJ SU ON (SU.SU_NR = FH.FH_PROJ) AND (SU.SU_SUB
= FH.FH_SUBPROJ)
LEFT OUTER JOIN VERTEW VE ON VE.VE_COD = FH.FH_AGT
LEFT OUTER JOIN TRANSPORTEUR TR ON TR.TR_CODE = FH.FH_TRANSPORTEUR
LEFT OUTER JOIN WEDERVERKOPERS WE ON WE.WE_COD = FH.FH_WEDERVERKOPER
WHERE (FH.FH_CODE = 'B')
Plan
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (FH INDEX (FH_CODE_INDEX),KL
INDEX (RDB$PRIMARY36)),PR INDEX (RDB$PRIMARY55)),SU NATURAL),VE INDEX
(RDB$PRIMARY76)),TR INDEX (RDB$PRIMARY167)),WE INDEX (RDB$PRIMARY292))
Adapted Plan
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (FH INDEX (FH_CODE_INDEX),KL
INDEX (INTEG_96)),PR INDEX (INTEG_142)),SU NATURAL),VE INDEX
(INTEG_205)),TR INDEX (INTEG_369)),WE INDEX (INTEG_703))
Many thanks !
Best regards,
Nico