pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jnasby@pervasive.com>
To: Svenne Krap <svenne@krap.dk>
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance problems with multiple layers of functions
Date: Fri, 24 Mar 2006 06:59:19 -0600
Message-ID: <20060324125919.GD90527@pervasive.com> (raw)
In-Reply-To: <4423EACD.80706@krap.dk>
References: <4423EACD.80706@krap.dk>

On Fri, Mar 24, 2006 at 01:49:17PM +0100, Svenne Krap wrote:
> explain select dataset_id, entity, sum(amount) from entrydata_current 
> where  flow_direction in (select * from outflow_direction(dataset_id)) 
> and dataset_id in (select * from get_dataset_ids(122)) group by 
> dataset_id, entity;
<snip> 
> which does not return within 10 minutes - which is unacceptable.


The issue is that the planner has no way to know what's comming back
from get_dataset_ids.

I think your best bet will be to wrap that select into it's own function
and have that function prepare the query statement, going back to
hard-coded values. So you could do something like:

SQL := 'SELECT ... AND dataset_id IN (''' || get_dataset_ids(122) ||
''');' (yeah, I know that won't work as written, but you get the idea).
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



view thread (5+ messages)  latest in thread

Message-ID: <20060324125919.GD90527@pervasive.com>
Permalink:  ../20060324125919.GD90527@pervasive.com/
Also on:    postgresql.org/message-id/20060324125919.GD90527@pervasive.com

 · 

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: jnasby@pervasive.com, svenne@krap.dk
  Subject: Re: Performance problems with multiple layers of functions
  In-Reply-To: <20060324125919.GD90527@pervasive.com>

* 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