Re: simple query runs 26 seconds - Mailing list pgsql-general

From Andrus
Subject Re: simple query runs 26 seconds
Date
Msg-id faufou$2bq$1@news.hub.org
Whole thread Raw
In response to simple query runs 26 seconds  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
> Perhaps that table is bloated by lack of vacuuming --- can you
> show the output from "vacuum verbose rid"?

Thank you.

After running vacuum and analyze commands the query takes 18 seconds.
This is still very slow because my tables are indexed.
How to speed up this ?

set search_path to firma1,public;explain analyze select sum(taitmata) as
ukogus
   from rid join dok using (dokumnr)
   where toode='NE TR'
     and doktyyp='U'

now returns:

"Aggregate  (cost=52251.18..52251.19 rows=1 width=8) (actual
time=17898.967..17898.967 rows=1 loops=1)"
"  ->  Hash Join  (cost=1182.35..52249.39 rows=715 width=8) (actual
time=4891.581..17898.897 rows=9 loops=1)"
"        Hash Cond: (rid.dokumnr = dok.dokumnr)"
"        ->  Bitmap Heap Scan on rid  (cost=777.92..51694.85 rows=22874
width=12) (actual time=24.079..17876.282 rows=21383 loops=1)"
"              Recheck Cond: (toode = 'NE TR'::bpchar)"
"              ->  Bitmap Index Scan on rid_toode_idx  (cost=0.00..772.20
rows=22874 width=0) (actual time=11.474..11.474 rows=21388 loops=1)"
"                    Index Cond: (toode = 'NE TR'::bpchar)"
"        ->  Hash  (cost=365.33..365.33 rows=3128 width=4) (actual
time=0.104..0.104 rows=7 loops=1)"
"              ->  Index Scan using dok_tasudok_unique_idx on dok
(cost=0.00..365.33 rows=3128 width=4) (actual time=0.058..0.089 rows=7
loops=1)"
"                    Index Cond: (doktyyp = 'U'::bpchar)"
"Total runtime: 17899.582 ms"

Andrus.



pgsql-general by date:

Previous
From: Sanjay
Date:
Subject: EXPLAIN ANALYZE not considering primary and unique indices!
Next
From: "Franck Roubieu - AXCENTEO"
Date:
Subject: How to restore my database ?