From: Tom Lane <tgl@sss.pgh.pa.us>
To: Craig James <cjames@emolecules.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: 100x slowdown for nearly identical tables
Date: Wed, 01 May 2013 20:18:32 -0400
Message-ID: <7768.1367453912@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFwQ8rfY0X_uMiAczWz4tp+E=mFQC0ohMt-F1MrETMDKVBXqBw@mail.gmail.com>
References: <CAFwQ8rfY0X_uMiAczWz4tp+E=mFQC0ohMt-F1MrETMDKVBXqBw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Craig James <cjames@emolecules.com> writes:
> I have two tables that are nearly identical, yet the same query runs 100x
> slower on the newer one. ...
> db=> explain analyze select id, 1 from str_conntab
> where (id >= 12009977 and id <= 12509976) order by id;
> Index Scan using new_str_conntab_pkey_3217 on str_conntab
> (cost=0.00..230431.33 rows=87827 width=4)
> (actual time=65.771..51341.899 rows=48613 loops=1)
> Index Cond: ((id >= 12009977) AND (id <= 12509976))
> Total runtime: 51350.556 ms
> db=> explain analyze select id, 1 from old_str_conntab
> where (id >= 12009977 and id <= 12509976) order by id;
> Index Scan using str_conntab_pkey on old_str_conntab
> (cost=0.00..82262.56 rows=78505 width=4)
> (actual time=38.327..581.235 rows=48725 loops=1)
> Index Cond: ((id >= 12009977) AND (id <= 12509976))
> Total runtime: 586.071 ms
It looks like old_str_conntab is more or less clustered by "id",
and str_conntab not so much. You could try EXPLAIN (ANALYZE, BUFFERS)
(on newer PG versions) to verify how many distinct pages are getting
touched during the indexscan.
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
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, cjames@emolecules.com
Subject: Re: 100x slowdown for nearly identical tables
In-Reply-To: <7768.1367453912@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