Subject | Additional optimalization |
---|---|
Author | Roland Turcan |
Post date | 2009-01-02T16:24:34Z |
Hello FireBird Support!
I have this SQL statement in store procedure:
SELECT A.JEDIN,A.ROK,EXTRACT(YEAR FROM A.DATUM_VYSTAVENIA),A.DRUH_DOKLADU,
A.CISLO,A.DATUM_VYSTAVENIA,A.DATUM_UCTOVANIA,
A.DATUM_SPLATNOSTI,B.NAZOV_UPLNY,A.VARIABILNY_SYMBOL,A.UCTOVNY_UCET,
A.PRIJEM-A.VYDAJ,B.JEDIN,
(SELECT SUM(C.MA_DAT-C.DAL) FROM SALDOKONTO C WHERE
C.DATUM <= '2008/12/31' AND
C.PAROVACIE_CISLO = (SELECT FIRST 1 D.PAROVACIE_CISLO
FROM SALDOKONTO D
WHERE D.FAKTURY_JEDIN=A.JEDIN))
FROM FAKTURY A
LEFT JOIN ADRESAR B ON B.JEDIN=A.ADRESAR
WHERE A.DATUM_VYSTAVENIA<='2008/12/31' AND A.TYP_DOKLADU=4;
which has execution plan:
PLAN (D INDEX (FK_SALDOKONTO_FAKTURY))
PLAN (C INDEX (IDX_SALDOKONTO_PAROVACIE_CISLO, IDX_SALDOKONTO_DATUM))
PLAN JOIN (A INDEX (IDX_FAKTURY_DATUM_VYSTAVENIA), B INDEX (RDB$PRIMARY3))
where is no more natural selection, but the subselect gets it slow and
I have no more idea how to get it faster.
Any idea?
Many thanks in advance.
I'm using Firebird 2.1.
--
Best regards, TRoland
http://www.rotursoft.sk
http://exekutor.rotursoft.sk
I have this SQL statement in store procedure:
SELECT A.JEDIN,A.ROK,EXTRACT(YEAR FROM A.DATUM_VYSTAVENIA),A.DRUH_DOKLADU,
A.CISLO,A.DATUM_VYSTAVENIA,A.DATUM_UCTOVANIA,
A.DATUM_SPLATNOSTI,B.NAZOV_UPLNY,A.VARIABILNY_SYMBOL,A.UCTOVNY_UCET,
A.PRIJEM-A.VYDAJ,B.JEDIN,
(SELECT SUM(C.MA_DAT-C.DAL) FROM SALDOKONTO C WHERE
C.DATUM <= '2008/12/31' AND
C.PAROVACIE_CISLO = (SELECT FIRST 1 D.PAROVACIE_CISLO
FROM SALDOKONTO D
WHERE D.FAKTURY_JEDIN=A.JEDIN))
FROM FAKTURY A
LEFT JOIN ADRESAR B ON B.JEDIN=A.ADRESAR
WHERE A.DATUM_VYSTAVENIA<='2008/12/31' AND A.TYP_DOKLADU=4;
which has execution plan:
PLAN (D INDEX (FK_SALDOKONTO_FAKTURY))
PLAN (C INDEX (IDX_SALDOKONTO_PAROVACIE_CISLO, IDX_SALDOKONTO_DATUM))
PLAN JOIN (A INDEX (IDX_FAKTURY_DATUM_VYSTAVENIA), B INDEX (RDB$PRIMARY3))
where is no more natural selection, but the subselect gets it slow and
I have no more idea how to get it faster.
Any idea?
Many thanks in advance.
I'm using Firebird 2.1.
--
Best regards, TRoland
http://www.rotursoft.sk
http://exekutor.rotursoft.sk