Subject | Re: [firebird-support] Performance of long GROUP BY clause |
---|---|
Author | Ann W. Harrison |
Post date | 2006-05-02T20:43:53Z |
t.s. wrote:
the group by clause, so, sooner or later, you're going to run out
of sort key size - and sorting is going to be affected by the key
size. What I would do is use aggregates even on the fields that
have a 1:1 dependence on the XXX_CODE fields. E.g.
select MAX(CUSTOMER_NAME), MIN(PRODUCT_NAME) from ...
group by CUSTOMER_CODE, PRODUCT_CODE
Don't use AVG or SUM...
Regards,
Ann
> Hello everyone,The grouping is done by sorting the input stream by the fields in
>
> Basically, this particular query returns the total sales grouped by
> TRANS_DATE, CUSTOMER_CODE, PRODUCT_CODE, and SALES_CODE.
>
> But to make the query more 'useful' i'd have to add more columns to the
> SELECT clause, for example, i'd need the CUSTOMER_NAME, PRODUCT_NAME,
> PRODUCT_DESCRIPTION, etc, etc.
the group by clause, so, sooner or later, you're going to run out
of sort key size - and sorting is going to be affected by the key
size. What I would do is use aggregates even on the fields that
have a 1:1 dependence on the XXX_CODE fields. E.g.
select MAX(CUSTOMER_NAME), MIN(PRODUCT_NAME) from ...
group by CUSTOMER_CODE, PRODUCT_CODE
Don't use AVG or SUM...
Regards,
Ann