simple query runs 26 seconds

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: simple query runs 26 seconds
Date: 2007-08-24 10:50:22
Message-ID: famd5o$1o2j$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have W2K server, relatively small database containing all required indexes
and need to sum only few records.

My query takes 26 seconds to run.
How to fix this ?

Andrus.

explain analyze select sum(taitmata) as ukogus
from rid join dok using (dokumnr)
where toode='NE TR'
and doktyyp='U'

returns

"Aggregate (cost=47581.25..47581.26 rows=1 width=8) (actual
time=26462.178..26462.178 rows=1 loops=1)"
" -> Hash Join (cost=1175.91..47579.54 rows=684 width=8) (actual
time=26462.002..26462.108 rows=7 loops=1)"
" Hash Cond: (rid.dokumnr = dok.dokumnr)"
" -> Bitmap Heap Scan on rid (cost=673.35..46946.99 rows=19703
width=12) (actual time=19.864..26430.100 rows=21335 loops=1)"
" Recheck Cond: (toode = 'NE TR'::bpchar)"
" -> Bitmap Index Scan on rid_toode_idx (cost=0.00..668.42
rows=19703 width=0) (actual time=12.402..12.402 rows=21335 loops=1)"
" Index Cond: (toode = 'NE TR'::bpchar)"
" -> Hash (cost=458.47..458.47 rows=3528 width=4) (actual
time=0.141..0.141 rows=6 loops=1)"
" -> Index Scan using dok_tasudok_unique_idx on dok
(cost=0.00..458.47 rows=3528 width=4) (actual time=0.057..0.125 rows=6
loops=1)"
" Index Cond: (doktyyp = 'U'::bpchar)"
"Total runtime: 26462.551 ms"

using

"PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2
(mingw-special)"

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2007-08-24 10:56:01 Re: Apache + PHP + Postgres Interaction
Previous Message Christian Schröder 2007-08-24 09:49:06 Re: "out of memory" error