Search Postgresql Archives

Re: simple query runs 26 seconds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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. 



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux