Skip site navigation (1) Skip section navigation (2)

Re: Optimizing Queries Joining Several Views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mailing(dot)lists(at)octgsoftware(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimizing Queries Joining Several Views
Date: 2012-01-27 02:15:32
Message-ID: 17443.1327630532@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Jason Long <mailing(dot)lists(at)octgsoftware(dot)com> writes:
> In order to do some complex calculations I have joined several views.
> Each view could join quite a few tables.

> The user is allowed to filter the results with several multi-select
> input fields and this is used in the query as where a.id in
> (:listOfIds).

> This works fine if the user does not filter the results.  These calcs
> for every row in the entire can be calculated in 1-2 seconds.  Certain
> combinations of filters will make the query take up to 4 minutes and
> will freeze the system until it has completed.  Queries without these
> calcs at all, but using the same filters work in a reasonable amount of
> time.

You're much more likely to get useful comments if you provide a concrete
example and EXPLAIN ANALYZE results for the various cases.

			regards, tom lane

In response to

pgsql-general by date

Next:From: Sebastian TennantDate: 2012-01-27 08:26:36
Subject: Re: Help needed creating a view
Previous:From: Tom LaneDate: 2012-01-27 00:54:11
Subject: Re: How to push predicate down

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group