Subject | Re: Slow query when using ORDER BY |
---|---|
Author | Adam |
Post date | 2006-02-06T05:02:35Z |
--- In firebird-support@yahoogroups.com, "markd_mms" <spam@...> wrote:
the index, read the data than to read it in storage order and sort in
memory.
You could try changing the order by to
ORDER BY ITEM.TITLE || '' ASC
This would force the index to not be used.
Otherwise, post the plan of the fast query and slow query so we can
see the likely culprits.
Adam
>following
> I'm having trouble with the following query. When I run the
> it returns 14016 record in just over 4 seconds:AS "Genre",
>
> SELECT ITEM.TITLE AS "Title", ITEM.TITLE2 AS "Title2",
> ITEMINFORMAT.CATALOGUENO AS "Catalogue Number",
> ITEMINFORMAT.BARCODE AS "Barcode", FORMATS.DESCRIPTION AS "Format",
> DISTRIBUTORS.DESCRIPTION AS "Distributor", GENRES.DESCRIPTION
> ITEM.DISTRIBUTOR_RELEASE_DATE AS "Release Date", ITEM.ITEMIDDISTRIBUTORS.DISTRIBUTORID
> FROM ITEM
> LEFT JOIN ITEMINFORMAT ON ITEMINFORMAT.ITEMID = ITEM.ITEMID
> LEFT JOIN ACTORITEM ON ITEM.ITEMID = ACTORITEM.ITEMID
> LEFT JOIN ACTORS ON ACTORITEM.ACTORID = ACTORS.ACTORID
> LEFT JOIN FORMATS ON ITEMINFORMAT.FORMATID = FORMATS.FORMATID
> LEFT JOIN DISTRIBUTORS ON ITEM.DISTRIBUTORID =
> LEFT JOIN GENRES ON ITEM.GENREID = GENRES.GENREIDon
>
> but as soon as I add
>
> ORDER BY ITEM.TITLE ASC
>
> the query takes over 4 minutes to run. There is an ascending index
> ITEM.TITLE that I tried removing but it doesn't make a difference.It could take much more time to read the index, read the data, read
>
> Does anyone know why it could be making such a big difference?
>
> TIA
> Mark
>
the index, read the data than to read it in storage order and sort in
memory.
You could try changing the order by to
ORDER BY ITEM.TITLE || '' ASC
This would force the index to not be used.
Otherwise, post the plan of the fast query and slow query so we can
see the likely culprits.
Adam