Re: Trying to figure out why these queries are so slow
От | Thomas Guettler |
---|---|
Тема | Re: Trying to figure out why these queries are so slow |
Дата | |
Msg-id | 4CAAF0D5.5010204@tbz-pariv.de обсуждение исходный текст |
Ответ на | Trying to figure out why these queries are so slow (Tim Uckun <timuckun@gmail.com>) |
Список | pgsql-general |
Hi, just a guess: Counting is slow, since it needs to check all rows. Explained here: http://wiki.postgresql.org/wiki/Slow_Counting Thomas Güttler Tim Uckun wrote: > I have two tables. Table C has about 300K records in it. Table E has > about a million records in it. Today I tried to run this query. > > update C > set result_count = X.result_count > from C > inner join (select c_id, count(c_id) as result_count > from E > where c_id is not null > group by c_id) as X > on C.id = X.c_id > > All the fields mentioned are indexed. In the case of Table C it's the > primary key. In the case table E it's just an index (non unique). > > I let this query run for about three hours before I cancelled it. > ... -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de
В списке pgsql-general по дате отправления: