pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ang Chin Han <angch@pintoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Functions too slow, even with iscachable?
Date: Wed, 9 Aug 2000 14:50:29 +0800
Message-ID: <20000809145029.A5894@pintoo.com> (raw)
In-Reply-To: <6058.965660307@sss.pgh.pa.us>
References: <20000807171110.A31838@pintoo.com>
	<6058.965660307@sss.pgh.pa.us>

On Mon, Aug 07, 2000 at 10:58:27AM -0400, Tom Lane wrote:

> (I assume the lack of "survey_id =" here is just a cut-and-paste error?)

Yup. :)

> I think what you're getting bit by is that the optimizer doesn't
> recognize "var = function(param)" as being a potential indexscan clause.
> Does EXPLAIN show that the first query is producing an indexscan plan?

It did. I'll try to make up a reproducible test case, if you need
it.

> I have not tried it, but I think you could get around this problem in
> plpgsql, along the lines of
> 	tmp1 = ticket2name($1);
> 	tmp2 = ticket2survey_id($1);
> 	SELECT passwd FROM ticket WHERE name = tmp1 AND survey_id = tmp2;
> since the tmp vars will look like params to the optimizer and "var = param"
> is indexable.

Yup, it did work. Thanks!

> Looks like we need to teach the optimizer that expressions involving
> params can be treated like simple params for the purposes of
> optimization.

That'll be good. Anything to speed up the stored procedures are good:
encourage people to put logic processing into the RDBMS where it should
be.



view thread (8+ messages)

Message-ID: <20000809145029.A5894@pintoo.com>
Permalink:  ../20000809145029.A5894@pintoo.com/
Also on:    postgresql.org/message-id/20000809145029.A5894@pintoo.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: angch@pintoo.com, tgl@sss.pgh.pa.us
  Subject: Re: Functions too slow, even with iscachable?
  In-Reply-To: <20000809145029.A5894@pintoo.com>
  References: <20000807171110.A31838@pintoo.com> <6058.965660307@sss.pgh.pa.us> <20000809145029.A5894@pintoo.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