Performance issue: index not used on GROUP BY...

Поиск
Список
Период
Сортировка
От gmb
Тема Performance issue: index not used on GROUP BY...
Дата
Msg-id 1409215840535-5816702.post@n5.nabble.com
обсуждение исходный текст
Ответы Re: Performance issue: index not used on GROUP BY...  (Victor Yegorov <vyegorov@gmail.com>)
Список pgsql-performance
Hi all

I have the following table with 10+ million records:

create table ddetail (
ddet_id serial,
co_id integer,
client_id integer,
doc_no varchar,
line_id integer,
batch_no integer,
amount NUMERIC ,
...,
constraint PRIMAR KEY (  co_id ,  client_id , doc_no ,  line_id, ddet_id )
) ;

When doing the following query on this table, performance is really slow:

SELECT  co_id ,  client_id , doc_no ,  line_id , sum( amount  )
FROM ddetail
GROUP BY co_id ,  client_id , doc_no ,  line_id

It seems as if the planner is not using the PRIMARY KEY as index which was
my assumption.

Can somebody please confirm whether aggregate functions such as GROUP BY
should use indexes ?


Thanks in advance

gmb



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Performance-issue-index-not-used-on-GROUP-BY-tp5816702.html
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.


В списке pgsql-performance по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: autocommit (true/false) for more than 1 million records
Следующее
От: Victor Yegorov
Дата:
Сообщение: Re: Performance issue: index not used on GROUP BY...