From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Mario Splivalo <mario(dot)splivalo(at)megafon(dot)hr> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query much slower when run from postgres function |
Date: | 2009-03-09 23:36:10 |
Message-ID: | 17869.1236641770@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc pgsql-performance |
Mario Splivalo <mario(dot)splivalo(at)megafon(dot)hr> writes:
> So, it is the same. When I do EXPLAIN ANALYZE EXECUTE I get completely
> different execution plan:
> ...
> -> Bitmap Heap Scan on messages
> (cost=287.98..21192.42 rows=12848 width=4) (actual time=0.049..0.169
> rows=62 loops=1)
> Recheck Cond: (service_id = $1)
> -> Bitmap Index Scan on
> messages_uq__service_id__tan (cost=0.00..284.77 rows=12848 width=0)
> (actual time=0.038..0.038 rows=62 loops=1)
> Index Cond: (service_id = $1)
Well, there's the problem: without knowing what the specific service_id
is, the planner is estimating 12848 matching rows, which is evidently
off by a couple of orders of magnitude. And that's pushing it to adopt
a hash join instead of a nestloop. Are you sure the stats on this
table are up to date? Maybe you need to increase the stats target?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Dickson S. Guedes | 2009-03-10 01:55:19 | Renaming sequence auto generated by SERIAL type don't update pg_attrdef |
Previous Message | Kris Jurka | 2009-03-09 22:39:03 | Re: getGeneratedKeys |
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Wong | 2009-03-10 00:57:21 | Re: DBT Presentation Location? |
Previous Message | Mario Splivalo | 2009-03-09 22:13:32 | Re: Query much slower when run from postgres function |