Subject RE: [firebird-support] Where is the time does ???
Author Svein Erling Tysvær
Hi Belal!

First, using indexes takes time - it is quicker to do a NATURAL scan on an entire table than use indexes.

Second, indexes saves you a lot of time. You can find a record much quicker with an index than a NATURAL scan, since it can skip checking many irrelevant records.

What you observe I'd say sounds sensible if you're reading an entire table, i.e. have a SELECT statement that lacks a WHERE clause (though I don't know how much extra time it should take using an index, so I can't say whether doubling the time would be typical or not, it just sounds sensible to me).

In most cases, it is not sensible to read the entire table. To all SELECT statements that I write, I add a WHERE clause wherever possible. Those rare cases where this isn't possible I find to occur with statements that are rarely used, and where it doesn't really matter whether whatever I'm trying to do finishes within one second or one hour.

Hence, my advice would be to see if you can add a WHERE clause to limit the returned number of rows from your statement, and if you have a WHERE clause, then check whether an index is used for the WHERE part.


-----Original Message-----
From: [] On Behalf Of redtneen
Sent: 5. september 2007 20:35
Subject: [firebird-support] Where is the time does ???

Hi All

i have procedure contain this statement

select .....
into .....

it take about 3s to execute

i had to add order by Field

select .....
order by Field
into .....

it take about 6s to execute

although this field is Indexed and the optimizer uses this index
(no sort was performed)

i need to know where this time goes in if possible how to sppeed up
this statement

my regards to all
belal al-hamed