From: Nick Hofstede <Nick.Hofstede@inventivegroup.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: suboptimal query plan
Date: Wed, 3 Oct 2012 08:02:49 +0000
Message-ID: <BC885F9E3DB48248A4C9FC7F2C57215C2DAC8530@Hoefnix.dc.intranet> (raw)
In-Reply-To: <24277.1349236493@sss.pgh.pa.us>
References: <BC885F9E3DB48248A4C9FC7F2C57215C2DAC8294@Hoefnix.dc.intranet>
<24277.1349236493@sss.pgh.pa.us>
That fixed it :)
The 9.2 query plan for reference:
Sort (cost=439.67..439.74 rows=30 width=503) (actual time=0.754..0.756 rows=49 loops=1)
Sort Key: s0_m0_msubjobs.creation_mdate, s0_m1_mjob.__id, s0_m0_msubjobs.__id
Sort Method: quicksort Memory: 31kB
-> Hash Join (cost=23.45..438.93 rows=30 width=503) (actual time=0.213..0.718 rows=49 loops=1)
Hash Cond: (s0_m0_msubjobs.job_mid = s0_m1_mjob.__id)
-> Nested Loop Semi Join (cost=5.20..420.27 rows=30 width=484) (actual time=0.054..0.543 rows=49 loops=1)
-> Bitmap Heap Scan on "subJobs" s0_m0_msubjobs (cost=5.20..54.08 rows=30 width=484) (actual time=0.040..0.102 rows=49 loops=1)
Recheck Cond: ((status)::text = 'IN_PROGRESS'::text)
Filter: ((validation_mrequired)::text = 'Y'::text)
Rows Removed by Filter: 76
-> Bitmap Index Scan on subjob_status (cost=0.00..5.19 rows=125 width=0) (actual time=0.029..0.029 rows=125 loops=1)
Index Cond: ((status)::text = 'IN_PROGRESS'::text)
-> Nested Loop (cost=0.00..307.45 rows=307 width=16) (actual time=0.009..0.009 rows=1 loops=49)
-> Index Only Scan using "subJobs_mid_mindex" on "subJobs" s1_m0_msubjobs (cost=0.00..5.34 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=49)
Index Cond: (__id = s0_m0_msubjobs.__id)
Heap Fetches: 49
-> Index Scan using "unit_msubJobs_mid_mindex" on unit s1_m1_munit (cost=0.00..299.03 rows=307 width=8) (actual time=0.006..0.006 rows=1 loops=49)
Index Cond: ("subJobs_mid" = s1_m0_msubjobs.__id)
Filter: ((validated IS NULL) OR ((validated)::text = 'N'::text))
-> Hash (cost=12.00..12.00 rows=500 width=27) (actual time=0.149..0.149 rows=500 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 30kB
-> Seq Scan on job s0_m1_mjob (cost=0.00..12.00 rows=500 width=27) (actual time=0.003..0.071 rows=500 loops=1)
Total runtime: 0.818 ms
Great work,
Nick Hofstede
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: woensdag 3 oktober 2012 5:55
To: Nick Hofstede
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] suboptimal query plan
Nick Hofstede <Nick.Hofstede@inventivegroup.com> writes:
> I'm struggling with a query that seems to use a suboptimal query plan.
Try it in 9.2 - this is the same type of join ordering restriction complained of last week here:
http://archives.postgresql.org/pgsql-performance/2012-09/msg00201.php
regards, tom lane
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
--
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
________________________________
Inventive Designers' Email Disclaimer:
http://www.inventivedesigners.com/email-disclaimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: Nick.Hofstede@inventivegroup.com, tgl@sss.pgh.pa.us
Subject: Re: suboptimal query plan
In-Reply-To: <BC885F9E3DB48248A4C9FC7F2C57215C2DAC8530@Hoefnix.dc.intranet>
References: <BC885F9E3DB48248A4C9FC7F2C57215C2DAC8294@Hoefnix.dc.intranet> <24277.1349236493@sss.pgh.pa.us> <BC885F9E3DB48248A4C9FC7F2C57215C2DAC8530@Hoefnix.dc.intranet>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox