pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Meinel <john@johnmeinel.com>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32@postgresql.org>
Subject: Re: Poor Performance for large queries in functions
Date: Wed, 29 Sep 2004 01:10:47 -0400
Message-ID: <22682.1096434647@sss.pgh.pa.us> (raw)
In-Reply-To: <415A288F.2030002@johnmeinel.com>
References: <4155C955.40808@dunslane.net>
	<415A288F.2030002@johnmeinel.com>

John Meinel <john@johnmeinel.com> writes:
> ... However, if I try to 
> bundle this query up into a server side function, it runs very slow (10 
> seconds). I'm trying to figure out why, but since I can't run EXPLAIN 
> ANALYZE inside a function, I don't really know what else to do.

A parameterized query inside a function is basically the same as a
PREPARE'd query with parameters at the SQL level.  So you can
investigate what's happening here with

	PREPARE foo(int) AS
		SELECT * FROM object WHERE id in (
			SELECT id FROM data_t WHERE project_id = $1
		UNION SELECT ... ;

	EXPLAIN ANALYZE EXECUTE foo(48542);

I'm not sure where the problem is either, so please do send along the
results.

			regards, tom lane

PS: pgsql-performance would be a more appropriate venue for this
discussion.



view thread (4+ messages)  latest in thread

Message-ID: <22682.1096434647@sss.pgh.pa.us>
Permalink:  ../22682.1096434647@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22682.1096434647@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, john@johnmeinel.com, pgsql-hackers-win32@postgresql.org
  Subject: Re: Poor Performance for large queries in functions
  In-Reply-To: <22682.1096434647@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