pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Pablo Alcaraz <pabloa@laotraesquina.com.ar>
Cc: pgsql-performance@postgresql.org
Subject: Re: Speed difference between select ... union select ... and select from partitioned_table
Date: Fri, 26 Oct 2007 14:07:01 -0700
Message-ID: <1193432821.7624.83.camel@dogma.ljc.laika.com> (raw)
In-Reply-To: <47225014.5040101@laotraesquina.com.ar>
References: <47225014.5040101@laotraesquina.com.ar>

On Fri, 2007-10-26 at 16:37 -0400, Pablo Alcaraz wrote:
> Hi List!
> 
> I executed 2 equivalents queries. The first one uses a union structure. 
> The second uses a partitioned table. The tables are the same with 30 
> millions of rows each one and the returned rows are the same.
> 
> But the union query perform faster than the partitioned query.
> 

I think you mean to use UNION ALL here. UNION forces a DISTINCT, which
results in a sort operation. What surprises me is that the UNION is
actually faster than the partitioning using inheritance.

I suspect it has something to do with the GROUP BYs, but we won't know
until you post EXPLAIN ANALYZE results.

    Regards,
	Jeff Davis




view thread (8+ messages)  latest in thread

Message-ID: <1193432821.7624.83.camel@dogma.ljc.laika.com>
Permalink:  ../1193432821.7624.83.camel@dogma.ljc.laika.com/
Also on:    postgresql.org/message-id/1193432821.7624.83.camel@dogma.ljc.laika.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: pgsql@j-davis.com, pabloa@laotraesquina.com.ar
  Subject: Re: Speed difference between select ... union select ... and select from partitioned_table
  In-Reply-To: <1193432821.7624.83.camel@dogma.ljc.laika.com>

* 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