pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How does the planner execute unions?
2+ messages / 2 participants
[nested] [flat]

* How does the planner execute unions?
@ 2005-08-26 20:14  Chris Hoover <revoohc@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Chris Hoover @ 2005-08-26 20:14 UTC (permalink / raw)
  To: pgsql-performance

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=# explain select count(1) from clmhdr where hdr_user_id = 'user_id';
                                                               QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=42.48..42.48 rows=1 width=924)
   ->  Subquery Scan clmhdr  (cost=0.00..42.41 rows=30 width=924)
         ->  Append  (cost=0.00..42.41 rows=30 width=924)
               ->  Subquery Scan "*SELECT* 1"  (cost=0.00..7.07 rows=5
width=924)
                     ->  Index Scan using
clmhdr_live_hdr_user_id_hdr_clm_status_idx on clmhdr_live 
(cost=0.00..7.07 rows=5 width=924)
                           Index Cond: (hdr_user_id =
'user_id'::character varying)
               ->  Subquery Scan "*SELECT* 2"  (cost=0.00..7.07 rows=5
width=924)
                     ->  Index Scan using
clmhdr_2003_hdr_user_id_hdr_clm_status_idx on clmhdr_2003 
(cost=0.00..7.07 rows=5 width=924)
                           Index Cond: (hdr_user_id =
'user_id'::character varying)
               ->  Subquery Scan "*SELECT* 3"  (cost=0.00..7.07 rows=5
width=924)
                     ->  Index Scan using
clmhdr_2004_hdr_user_id_hdr_clm_status_idx on clmhdr_2004 
(cost=0.00..7.07 rows=5 width=924)
                           Index Cond: (hdr_user_id =
'user_id'::character varying)
               ->  Subquery Scan "*SELECT* 4"  (cost=0.00..7.07 rows=5
width=924)
                     ->  Index Scan using
clmhdr_2005_hdr_user_id_hdr_clm_status_idx on clmhdr_2005 
(cost=0.00..7.07 rows=5 width=924)
                           Index Cond: (hdr_user_id =
'user_id'::character varying)
               ->  Subquery Scan "*SELECT* 5"  (cost=0.00..7.07 rows=5
width=924)
                     ->  Index Scan using
clmhdr_2006_hdr_user_id_hdr_clm_status_idx on clmhdr_2006 
(cost=0.00..7.07 rows=5 width=924)
                           Index Cond: (hdr_user_id =
'user_id'::character varying)
               ->  Subquery Scan "*SELECT* 6"  (cost=0.00..7.07 rows=5
width=924)
                     ->  Index Scan using
clmhdr_2007_hdr_user_id_hdr_clm_status_idx on clmhdr_2007 
(cost=0.00..7.07 rows=5 width=924)
                           Index Cond: (hdr_user_id =
'user_id'::character varying)
(21 rows)

hmd=#



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How does the planner execute unions?
@ 2005-08-26 20:45  Bruno Wolff III <bruno@wolff.to>
  parent: Chris Hoover <revoohc@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Bruno Wolff III @ 2005-08-26 20:45 UTC (permalink / raw)
  To: Chris Hoover <revoohc@gmail.com>; +Cc: pgsql-performance

On Fri, Aug 26, 2005 at 16:14:18 -0400,
  Chris Hoover <revoohc@gmail.com> wrote:
> 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).

Postgres doesn't have parallel execution of parts of queries. So it is
going to do one part followed by the other part.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-08-26 20:45 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-26 20:14 How does the planner execute unions? Chris Hoover <revoohc@gmail.com>
2005-08-26 20:45 ` Bruno Wolff III <bruno@wolff.to>

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