Re: [PERFORM] bad estimates / non-scanning aggregates

2003-08-29 Thread Bruno Wolff III
On Thu, Aug 28, 2003 at 20:00:32 -0700, Ken Geis <[EMAIL PROTECTED]> wrote: > Bruno Wolff III wrote: > >>Not according to the optimizer! Plus, this is not guaranteed to return > >>the correct results. > > > >For it to be fast you need an index on (stock_id, price_date) so that > >you can use an

Re: [PERFORM] bad estimates / non-scanning aggregates

2003-08-29 Thread Ken Geis
Bruno Wolff III wrote: Not according to the optimizer! Plus, this is not guaranteed to return the correct results. For it to be fast you need an index on (stock_id, price_date) so that you can use an index scan. I already said that such an index existed. In fact, it is the primary key of the ta

Re: [PERFORM] bad estimates / non-scanning aggregates

2003-08-29 Thread Bruno Wolff III
On Thu, Aug 28, 2003 at 19:50:38 -0700, Ken Geis <[EMAIL PROTECTED]> wrote: > Bruno Wolff III wrote: > >On Thu, Aug 28, 2003 at 17:10:31 -0700, > > Ken Geis <[EMAIL PROTECTED]> wrote: > > > >>The query I want to run is > >> > >>select stock_id, min(price_date) from day_ends group by stock_id; >

Re: [PERFORM] bad estimates / non-scanning aggregates

2003-08-29 Thread Ken Geis
Bruno Wolff III wrote: On Thu, Aug 28, 2003 at 17:10:31 -0700, Ken Geis <[EMAIL PROTECTED]> wrote: The query I want to run is select stock_id, min(price_date) from day_ends group by stock_id; The fast way to do this is: select distinct on (stock_id) stock_id, price_date order by stock_id, pri

Re: [PERFORM] bad estimates / non-scanning aggregates

2003-08-29 Thread Bruno Wolff III
On Thu, Aug 28, 2003 at 17:10:31 -0700, Ken Geis <[EMAIL PROTECTED]> wrote: > The query I want to run is > > select stock_id, min(price_date) from day_ends group by stock_id; The fast way to do this is: select distinct on (stock_id) stock_id, price_date order by stock_id, price_date; > Also

[PERFORM] bad estimates / non-scanning aggregates

2003-08-29 Thread Ken Geis
I'm surprised at the effort pgsql requires to run one of my queries. I don't know how to tune this query. Column | Type | Modifiers +--+--- the_id | integer | not null the_date | date | not null num1 | numeric(9,4) | num2