Subject | Firebird 1.5 Order by Query |
---|---|
Author | |
Post date | 2013-11-22T11:18:21Z |
Hi,
I have a simple query:
SELECT first 1 ITEM_DATE FROM HISTORY
WHERE ITEM_ID = 'ITEM_ID_123456'
and ITEM_TYPE = 'TYPE1'
AND ITEM_STATUS > 200 and ITEM_STATUS <> 310
ORDER BY ITEM_DATE ASC
Which runs in about 1.5 seconds. If I remove the Order by it's less than 100ms. There are only three records in the result set. There is an ascending index on ITEM_DATE and the statistics are up to date.
Does anyone know why there would be such a difference in performance when using\not using the order by? What is the engine ordering? It can't be the three records to take 1.5 seconds, surely?
Thanks,