Hier noch mal die Query:
explain insert into tmpEZP6
select
ezp2.nHid,
rdtid.nTraceId,
rdtid.vcid1,
rdtid.vcid2,
rdtid.vcid3,
rdtid.vcid4,
rdtid.nHid
from tabRDTraceId rdtid, tmpEZP2 ezp2
where
rdtid.vcSetupDate = ezp2.vcSetupDate;
and rdtid.vcLogicalId = ezp2.vcLogicalId
and rdtid.vcLine = ezp2.vcLine;
Momentan besteht ein zweidimensionaler Index auf (vcSetupDate,vcLogicalId). Dadurch das in der Where Klausel noch ein join über vcLine erfolgt, muss man dann nicht sequenziell durch die Tabelle (in dem Fall halt alle Kindertabellen) gehen?
nun habe ich mal 2 Test vorgenommen.
1.
- den Index habe ich von mehrdimensional auf eindimensional (nur vcSetupaDate) geändert
- die Query habe ich so angepasst:
explain insert into tmpEZP6
select
ezp2.nHid,
rdtid.nTraceId,
rdtid.vcid1,
rdtid.vcid2,
rdtid.vcid3,
rdtid.vcid4,
rdtid.nHid
from tabRDTraceId rdtid, tmpEZP2 ezp2
where
rdtid.vcSetupDate = ezp2.vcSetupDate;
-- and rdtid.vcLogicalId = ezp2.vcLogicalId
-- and rdtid.vcLine = ezp2.vcLine;
Die Selektierung druch die Where Klausel erfolgt jetzt nur noch auf der Spalte, welche einen Index hat.
Ergebnis: immer Index Scan und immer schnell
2.
- den Index habe ich von zweidimensionalen auf einen dreidimensional (vcSetupaDate, vcLogicalId,vcLine) geändert
- die Query habe ich das auskommentierte wieder gestrichen:
explain insert into tmpEZP6
select
ezp2.nHid,
rdtid.nTraceId,
rdtid.vcid1,
rdtid.vcid2,
rdtid.vcid3,
rdtid.vcid4,
rdtid.nHid
from tabRDTraceId rdtid, tmpEZP2 ezp2
where
rdtid.vcSetupDate = ezp2.vcSetupDate;
and rdtid.vcLogicalId = ezp2.vcLogicalId
and rdtid.vcLine = ezp2.vcLine;
Ergebnis: wieder Wechsel von Index Scan auf Sequenziellen.
Liegt meiner Meinung nach am Mehrdimensionalen Index.
mfg
Marcus