Обсуждение: Select very slow...

Поиск
Список
Период
Сортировка

Select very slow...

От
"Fernando Eduardo B. L. e Carvalho"
Дата:
   Table  1
   create table person (
                doc text primary key,
                etc ....
                city  text  );
  90000 rows
  create table sales (
                doc text,
                 etc .....
                 );
  300000 rows
 select  p.city,count(*) from sales s, person p where s.doc = p.doc
group by p.city;
  Anyone help-me?






Re: Select very slow...

От
David Olbersen
Дата:
On Sun, 18 Mar 2001, Fernando Eduardo B. L. e Carvalho wrote:

>   select  p.city,count(*) from sales s, person p where s.doc = p.doc
> group by p.city;
>
>    Anyone help-me?

1: VACUUM ANALYZE sales  VACUUM ANALYZE person;

2: That 'count(*)' is going to be slow.  Try counting a column that's indexed (p.doc might work?)

3: EXPLAIN <your select from above>;  That should give you some hints on what to optimize.

-- Dave



Re: Select very slow...

От
Joseph Shraibman
Дата:
David Olbersen wrote:
> 
> On Sun, 18 Mar 2001, Fernando Eduardo B. L. e Carvalho wrote:
> 
> >   select  p.city,count(*) from sales s, person p where s.doc = p.doc
> > group by p.city;
> >
> >    Anyone help-me?
> 
> 1: VACUUM ANALYZE sales
>    VACUUM ANALYZE person;
> 
> 2: That 'count(*)' is going to be slow.
>    Try counting a column that's indexed (p.doc might work?)
> 
I don't think that is true.


--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com