Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jona <jonanews(at)oismail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 1
Date: 2005-05-05 16:02:34
Message-ID: 24106.1115308954@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jona <jonanews(at)oismail(dot)com> writes:
> I'm currently experiencing problems with long query execution times.
> What I believe makes these problems particularly interesting is the
> difference in execution plans between our test server running PostGreSQL
> 7.3.6 and our production server running PostGreSQL 7.3.9.
> The test server is an upgraded "home machine", a Pentium 4 with 1GB of
> memory and IDE disk.
> The production server is a dual CPU XEON Pentium 4 with 2GB memory and
> SCSI disks.
> One should expect the production server to be faster, but appearently
> not as the outlined query plans below shows.

I think the plans are fine; it looks to me like the production server
has serious table-bloat or index-bloat problems, probably because of
inadequate vacuuming. For instance compare these entries:

-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4)
Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))

-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4)
Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))

Appears to be exactly the same task ... but the test server spent
1.24 msec total while the production server spent 687.36 msec total.
That's more than half of your problem right there. Some of the other
scans seem a lot slower on the production machine too.

> 1) How come the query plans between the 2 servers are different?

The production server's rowcount estimates are pretty good, the test
server's are not. How long since you vacuumed/analyzed the test server?

It'd be interesting to see the output of "vacuum verbose statcon_tbl"
on both servers ...

regards, tom lane

PS: if you post any more query plans, please try to use software that
doesn't mangle the formatting so horribly ...

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message David Roussel 2005-05-05 23:59:32 Re: Table stats
Previous Message Jona 2005-05-05 09:52:01 Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 1