pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Scott Marlowe <scott.marlowe@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: subselect requires offset 0 for good performance.
Date: Fri, 02 Aug 2013 15:31:18 -0400
Message-ID: <6895.1375471878@sss.pgh.pa.us> (raw)
In-Reply-To: <CAOR=d=02KtqKwD36UCu1wV3krbnQ_3T5yjjihONauCp_OhvwKA@mail.gmail.com>
References: <CAOR=d=2Fq-TzwzRf92BOeeHGqhkPXVG5_zs+_aR690ZxPp3JAg@mail.gmail.com>
	<4522.1375400642@sss.pgh.pa.us>
	<CAOR=d=3UVax7k_nT7Gm+Y2N0=0WZekT2dyOzxWM4wjsryfQL=Q@mail.gmail.com>
	<CAOR=d=02KtqKwD36UCu1wV3krbnQ_3T5yjjihONauCp_OhvwKA@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Scott Marlowe <scott.marlowe@gmail.com> writes:
> I extracted all the data like so:
> select * into dba.pp_test_wide from original table;
> and get this query plan from explain analyze:
> http://explain.depesz.com/s/EPx which takes 20 minutes to run.
> If I extract it this way:
> select tree_sortkey, product_name, deleted_at into db.pp_test_3col
> from original table;
> I get this plan: http://explain.depesz.com/s/gru which gets a
> materialize in it, and suddenly takes 106 ms.

There's no reason why suppressing some unrelated columns would change the
rowcount estimates, but those two plans show different rowcount estimates.

I suspect the *actual* reason for the plan change was that autovacuum had
had a chance to update statistics for the one table, and not yet for the
other.  Please do a manual ANALYZE on both tables and see if there's
still a plan difference.

			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



view thread (16+ messages)  latest in thread

Message-ID: <6895.1375471878@sss.pgh.pa.us>
Permalink:  ../6895.1375471878@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6895.1375471878@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, scott.marlowe@gmail.com
  Subject: Re: subselect requires offset 0 for good performance.
  In-Reply-To: <6895.1375471878@sss.pgh.pa.us>

* 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