From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Kojedzinszky <krichy@tvnetwork.hu>
Cc: pgsql-performance@postgresql.org
Subject: Re: query optimization
Date: Thu, 26 Apr 2012 15:17:18 -0400
Message-ID: <12228.1335467838@sss.pgh.pa.us> (raw)
In-Reply-To: <alpine.DEB.2.02.1204241008570.9591@krichy.tvnetwork.hu>
References: <alpine.DEB.2.02.1204241008570.9591@krichy.tvnetwork.hu>
Richard Kojedzinszky <krichy@tvnetwork.hu> writes:
> Dear list,
> We have a database schema, which looks the same as the attached script.
> When filling the tables with data, and skipping analyze on the table (so
> pg_stats contains no records for table 'a'), the first select in the
> script runs fast, but after an analyze the planner decides to sequence
> scan tables b and c, thus making the query much slower. Can somebody help
> me solving this issue, or tuning our installation to not to use sequence
> scans in this case?
Um ... did you analyze all the tables, or just some of them? I get
sub-millisecond runtimes if all four tables have been analyzed, but it
does seem to pick lousy plans if, say, only a and b have been analyzed.
What you really need for this query structure is the parameterized-path
work I've been doing for 9.2; but at least on the exact example given,
I'm not seeing that 9.1 is that much worse.
regards, tom lane
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, krichy@tvnetwork.hu
Subject: Re: query optimization
In-Reply-To: <12228.1335467838@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