| From: | Thomas Guettler <hv(at)tbz-pariv(dot)de> |
|---|---|
| To: | Tim Uckun <timuckun(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Trying to figure out why these queries are so slow |
| Date: | 2010-10-05 09:33:09 |
| Message-ID: | 4CAAF0D5.5010204@tbz-pariv.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tim Uckun | 2010-10-05 09:39:50 | Re: Trying to figure out why these queries are so slow |
| Previous Message | Tim Uckun | 2010-10-05 09:20:41 | Trying to figure out why these queries are so slow |