Subject Re: How to get a good performance
Author donoteatcarrot
Thank you for your kind help.

> Something is seriously wrong when
> SELECT MAX(field_A) as max_A, field_B FROM TABLEX GROUP BY field_B
> takes 20 minutes on a table that contains only 500000 records.

and sorry for my poor explaination.
Only after restarting the computer and I execute the query the first
time, it takes about 20 minutes.
there are also some UDFs, constraints, stored procedures, triggers
in the database.
but in this query:
select max(field_A), field_B from table_X group by field_B
table_X uses none of the UDFs, triggers ...
Field_A's data type is timestamp,
Field_B's data type is char(20).
Default character set is UNICODE_FSS.
Database file size is about 4G.
Page size is 4K.
and the second time of the execution takes about 15 seconds.

why the first time takes so much more time ?

And I found a document
http://www.firebirdsql.org/downloads/makeibscream.pdf
it sais ,
"Columns used in aggregate functions, like COUNT() do not use an
index."
Is that means even I add index to the table, the execution can not
be faster ? (because there is MAX() in that query)
In fact, I added both ASC and DESC index. The time of execution
really did not change so much.

> -I like carrots...
Thank you for you like carrots.
I like too, just because "eatcarrot@..." has been taken. :-)