Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TJJud-0005mz-64 for pgsql-performance@postgresql.org; Wed, 03 Oct 2012 08:02:35 +0000 Received: from ip-188-118-12-161.reverse.destiny.be ([188.118.12.161] helo=smtp.inventivegroup.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TJJua-0000YL-EJ for pgsql-performance@postgresql.org; Wed, 03 Oct 2012 08:02:34 +0000 From: Nick Hofstede To: Tom Lane CC: "pgsql-performance@postgresql.org" Subject: Re: suboptimal query plan Date: Wed, 3 Oct 2012 08:02:49 +0000 Message-ID: References: <24277.1349236493@sss.pgh.pa.us> In-Reply-To: <24277.1349236493@sss.pgh.pa.us> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Pg-Spam-Score: -0.9 (/) X-Archive-Number: 201210/18 X-Sequence-Number: 47977 That fixed it :) The 9.2 query plan for reference: Sort (cost=3D439.67..439.74 rows=3D30 width=3D503) (actual time=3D0.754..0= .756 rows=3D49 loops=3D1) Sort Key: s0_m0_msubjobs.creation_mdate, s0_m1_mjob.__id, s0_m0_msubjobs.= __id Sort Method: quicksort Memory: 31kB -> Hash Join (cost=3D23.45..438.93 rows=3D30 width=3D503) (actual time= =3D0.213..0.718 rows=3D49 loops=3D1) Hash Cond: (s0_m0_msubjobs.job_mid =3D s0_m1_mjob.__id) -> Nested Loop Semi Join (cost=3D5.20..420.27 rows=3D30 width=3D4= 84) (actual time=3D0.054..0.543 rows=3D49 loops=3D1) -> Bitmap Heap Scan on "subJobs" s0_m0_msubjobs (cost=3D5.2= 0..54.08 rows=3D30 width=3D484) (actual time=3D0.040..0.102 rows=3D49 loops= =3D1) Recheck Cond: ((status)::text =3D 'IN_PROGRESS'::text) Filter: ((validation_mrequired)::text =3D 'Y'::text) Rows Removed by Filter: 76 -> Bitmap Index Scan on subjob_status (cost=3D0.00..5= .19 rows=3D125 width=3D0) (actual time=3D0.029..0.029 rows=3D125 loops=3D1) Index Cond: ((status)::text =3D 'IN_PROGRESS'::te= xt) -> Nested Loop (cost=3D0.00..307.45 rows=3D307 width=3D16) = (actual time=3D0.009..0.009 rows=3D1 loops=3D49) -> Index Only Scan using "subJobs_mid_mindex" on "subJ= obs" s1_m0_msubjobs (cost=3D0.00..5.34 rows=3D1 width=3D8) (actual time=3D= 0.002..0.002 rows=3D1 loops=3D49) Index Cond: (__id =3D s0_m0_msubjobs.__id) Heap Fetches: 49 -> Index Scan using "unit_msubJobs_mid_mindex" on unit= s1_m1_munit (cost=3D0.00..299.03 rows=3D307 width=3D8) (actual time=3D0.0= 06..0.006 rows=3D1 loops=3D49) Index Cond: ("subJobs_mid" =3D s1_m0_msubjobs.__i= d) Filter: ((validated IS NULL) OR ((validated)::tex= t =3D 'N'::text)) -> Hash (cost=3D12.00..12.00 rows=3D500 width=3D27) (actual time= =3D0.149..0.149 rows=3D500 loops=3D1) Buckets: 1024 Batches: 1 Memory Usage: 30kB -> Seq Scan on job s0_m1_mjob (cost=3D0.00..12.00 rows=3D50= 0 width=3D27) (actual time=3D0.003..0.071 rows=3D500 loops=3D1) 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 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 complain= ed 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 MailScan= ner, and is believed to be clean. ________________________________ Inventive Designers' Email Disclaimer: http://www.inventivedesigners.com/email-disclaimer