X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 09F8ED7CC7 for ; Fri, 26 Aug 2005 17:14:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83212-01 for ; Fri, 26 Aug 2005 20:14:18 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) by svr1.postgresql.org (Postfix) with ESMTP id C1342D7CC5 for ; Fri, 26 Aug 2005 17:14:17 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 8so371206nzo for ; Fri, 26 Aug 2005 13:14:18 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=r2aY7OCC0toXKqqtLEzpZOItKZN991cIl7ZU/NdOkrAhE/+1zU3VrgCDWXtE8WwPoIHb20B8sfr6rRWwO7u7ZqEvi5M5HvWRfaQBFchUpY5tR4v6siKNVxFhdrL+97L2ZEtXOpLPRsh87AAMyVAesOoW2JodGXcNm2KcFJisPJY= Received: by 10.36.250.44 with SMTP id x44mr300895nzh; Fri, 26 Aug 2005 13:14:18 -0700 (PDT) Received: by 10.36.24.2 with HTTP; Fri, 26 Aug 2005 13:14:18 -0700 (PDT) Message-ID: <1d219a6f0508261314516fdb0@mail.gmail.com> Date: Fri, 26 Aug 2005 16:14:18 -0400 From: Chris Hoover To: pgsql-performance@postgresql.org Subject: How does the planner execute unions? Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200508/451 X-Sequence-Number: 14198 Hopefully a quick question. In 7.3.4, how does the planner execute a query with union alls in it? Does it execute the unions serially, or does it launch a "thread" for each union (or maybe something else entirely). Thanks, Chris Here is an explain from the view I'm thinking about, how does postgres run this query? hmd=3D# explain select count(1) from clmhdr where hdr_user_id =3D 'user_id'= ; QUERY PLAN ---------------------------------------------------------------------------= ------------------------------------------------------------- Aggregate (cost=3D42.48..42.48 rows=3D1 width=3D924) -> Subquery Scan clmhdr (cost=3D0.00..42.41 rows=3D30 width=3D924) -> Append (cost=3D0.00..42.41 rows=3D30 width=3D924) -> Subquery Scan "*SELECT* 1" (cost=3D0.00..7.07 rows=3D5 width=3D924) -> Index Scan using clmhdr_live_hdr_user_id_hdr_clm_status_idx on clmhdr_live=20 (cost=3D0.00..7.07 rows=3D5 width=3D924) Index Cond: (hdr_user_id =3D 'user_id'::character varying) -> Subquery Scan "*SELECT* 2" (cost=3D0.00..7.07 rows=3D5 width=3D924) -> Index Scan using clmhdr_2003_hdr_user_id_hdr_clm_status_idx on clmhdr_2003=20 (cost=3D0.00..7.07 rows=3D5 width=3D924) Index Cond: (hdr_user_id =3D 'user_id'::character varying) -> Subquery Scan "*SELECT* 3" (cost=3D0.00..7.07 rows=3D5 width=3D924) -> Index Scan using clmhdr_2004_hdr_user_id_hdr_clm_status_idx on clmhdr_2004=20 (cost=3D0.00..7.07 rows=3D5 width=3D924) Index Cond: (hdr_user_id =3D 'user_id'::character varying) -> Subquery Scan "*SELECT* 4" (cost=3D0.00..7.07 rows=3D5 width=3D924) -> Index Scan using clmhdr_2005_hdr_user_id_hdr_clm_status_idx on clmhdr_2005=20 (cost=3D0.00..7.07 rows=3D5 width=3D924) Index Cond: (hdr_user_id =3D 'user_id'::character varying) -> Subquery Scan "*SELECT* 5" (cost=3D0.00..7.07 rows=3D5 width=3D924) -> Index Scan using clmhdr_2006_hdr_user_id_hdr_clm_status_idx on clmhdr_2006=20 (cost=3D0.00..7.07 rows=3D5 width=3D924) Index Cond: (hdr_user_id =3D 'user_id'::character varying) -> Subquery Scan "*SELECT* 6" (cost=3D0.00..7.07 rows=3D5 width=3D924) -> Index Scan using clmhdr_2007_hdr_user_id_hdr_clm_status_idx on clmhdr_2007=20 (cost=3D0.00..7.07 rows=3D5 width=3D924) Index Cond: (hdr_user_id =3D 'user_id'::character varying) (21 rows) hmd=3D#