Subject | Re: [firebird-support] Re: Optimizing in (...) Statements |
---|---|
Author | Arno Brinkman |
Post date | 2004-10-14T13:55:06Z |
Hi Michael,
optimizer chooses wrong join order.
The query below should run fast, because it works around the currently
existing problems:
SELECT
SUM( VARER_DETAIL.ANTALSTK ) ANTALSTK,
SUM( VARER_DETAIL.BEH_KOSTPRIS ) BEH_KOSTPRIS,
SUM( VARER_DETAIL.BEH_SALGSPRIS ) SALGSPRIS,
SUM( VARER_DETAIL.BEH_SALGSPRISMOMS ) SALGSPRISMOMS,
VARER_DETAIL.AFDELING_ID,
VARER.LEVERID GRUP2,
LEVERANDOERER.V509Index GRUP2509,
Afdeling.Navn,
Afdeling.AfdInfo
FROM
VARER
JOIN Varer_Detail ON
((Varer_Detail.VarePlu_ID = Varer.Plu_Nr || '' and
Varer_detail.Afdeling_ID = '001') or
(Varer_Detail.VarePlu_ID = Varer.Plu_Nr || '' and
Varer_detail.Afdeling_ID = '002'))
JOIN Afdeling on (Afdeling.Afdelingsnummer = Varer_Detail.Afdeling_ID)
JOIN LEVERANDOERER on (Varer.LeverID=LEVERANDOERER.Navn)
GROUP BY
VARER_DETAIL.AFDELING_ID,
LEVERANDOERER.V509Index,
VARER.LEVERID,
Afdeling.Navn,
Afdeling.AfdInfo
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info
> AtI think the same problem as by m_quadrat, but also a second problem that the
>
> http://download.microcom.dk/T
>
> there is an packed DB to download.
>
> Size: 758 K
optimizer chooses wrong join order.
The query below should run fast, because it works around the currently
existing problems:
SELECT
SUM( VARER_DETAIL.ANTALSTK ) ANTALSTK,
SUM( VARER_DETAIL.BEH_KOSTPRIS ) BEH_KOSTPRIS,
SUM( VARER_DETAIL.BEH_SALGSPRIS ) SALGSPRIS,
SUM( VARER_DETAIL.BEH_SALGSPRISMOMS ) SALGSPRISMOMS,
VARER_DETAIL.AFDELING_ID,
VARER.LEVERID GRUP2,
LEVERANDOERER.V509Index GRUP2509,
Afdeling.Navn,
Afdeling.AfdInfo
FROM
VARER
JOIN Varer_Detail ON
((Varer_Detail.VarePlu_ID = Varer.Plu_Nr || '' and
Varer_detail.Afdeling_ID = '001') or
(Varer_Detail.VarePlu_ID = Varer.Plu_Nr || '' and
Varer_detail.Afdeling_ID = '002'))
JOIN Afdeling on (Afdeling.Afdelingsnummer = Varer_Detail.Afdeling_ID)
JOIN LEVERANDOERER on (Varer.LeverID=LEVERANDOERER.Navn)
GROUP BY
VARER_DETAIL.AFDELING_ID,
LEVERANDOERER.V509Index,
VARER.LEVERID,
Afdeling.Navn,
Afdeling.AfdInfo
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info