Subject | Re: [firebird-support] aggregate function optimization |
---|---|
Author | Helen Borrie |
Post date | 2004-11-05T05:32:32Z |
At 12:46 AM 5/11/2004 +0000, you wrote:
through the table.
foreign key. (!!!!) Make a composite index consisting of status + primary
key, *in that order*.
I'm not sure why your Subject for this question is "aggregate function
optimization". The optimization here applies to any search, including, but
not limited to, selecting the rows for an aggregation.
./hb
>Hi,This one is OK to index on its own, provided plenty of ids are distributed
>
>I will be using a lot of statements like this ...
>
>select sum(qty)
>from table
>where id = :id and status = :status
>
>in a table with tens of thousand record and eventually it will grow to
>hundreds of thousand record.
>
>What are the things I have to know/do to achieve maximum performace
>... the id field is a integer field where in the same value can be
>enormous in the table or just a few,
through the table.
>while the status is a char(3)Don't use a single-column index on this column and don't make this column a
>field where the possible value can be only 10, where in one of the
>value is dominating, like around 95% of the records have this same
>value and the rest share the other 9 possible value.
foreign key. (!!!!) Make a composite index consisting of status + primary
key, *in that order*.
I'm not sure why your Subject for this question is "aggregate function
optimization". The optimization here applies to any search, including, but
not limited to, selecting the rows for an aggregation.
./hb