Re: Controlling complexity in queries

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: Robert James <srobertjames(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Controlling complexity in queries
Date: 2011-12-12 03:10:21
Message-ID: 4EE5709D.4020108@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/12/2011 09:15 AM, David Johnston wrote:
> Use a WITH clause on the SELECT statement.
Note that WITH is an optimisation fence, so if you're relying on Pg
pushing WHERE clauses down into subqueries or anything like that you may
find that your query runs a LOT slower when broken up as WITH expressions.

There's been talk of a Pg extension that allows optimisation through
WITH, but it's not currently possible.

Another option is to wrap things up in SQL functions or views.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message devrim 2011-12-12 04:31:49 Re: Problem installing PG9.1 using yum
Previous Message Craig Ringer 2011-12-12 03:03:57 Re: Howto to clear PostgreSQL cache and how to preload all tuples of a table into the cache?