pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Sullivan <andrew@libertyrms.info>
Cc: pgsql-performance@postgresql.org, Oliver Siegmar <o.siegmar@vitrado.de>
Cc: Bill Moran <wmoran@potentialtech.com>
Subject: Re: PL/pgSQL functions - text / varchar - havy performance
Date: Fri, 29 Aug 2003 12:18:35 -0400
Message-ID: <28309.1062173915@sss.pgh.pa.us> (raw)
In-Reply-To: <20030829155401.GM19388@libertyrms.info>
References: <200308291554.46748.o.siegmar@vitrado.de>
	<3F4F6754.8050900@potentialtech.com>
	<20030829150151.GI19388@libertyrms.info>
	<3F4F7275.5030203@potentialtech.com>
	<20030829155401.GM19388@libertyrms.info>

Andrew Sullivan <andrew@libertyrms.info> writes:
> On Fri, Aug 29, 2003 at 11:34:13AM -0400, Bill Moran wrote:
>> Have any explanation as to why that function is so slow?

> Sorry, no.  It might have to do with the planning, though.

Specifically, I'll bet he's getting an indexscan plan with one and not
with the other.  It's just ye olde cross-datatype-comparisons-aren't-
indexable problem.  "varchar = varchar" matches the index on the varchar
column, but "text = text" is a different operator that doesn't match.
Guess which one gets selected when the initial input is "varchar = text".

7.4 has fixed this particular problem by essentially eliminating the
separate operators for varchar, but in prior releases the behavior
Oliver describes is entirely to be expected.  A workaround is to
cast inside the function:

	... where varcharcolumn = textarg::varchar;

so that "=" gets interpreted as "varchar = varchar".

			regards, tom lane



view thread (7+ messages)

Message-ID: <28309.1062173915@sss.pgh.pa.us>
Permalink:  ../28309.1062173915@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28309.1062173915@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 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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew@libertyrms.info, o.siegmar@vitrado.de, wmoran@potentialtech.com
  Subject: Re: PL/pgSQL functions - text / varchar - havy performance
  In-Reply-To: <28309.1062173915@sss.pgh.pa.us>
  References: <200308291554.46748.o.siegmar@vitrado.de> <3F4F6754.8050900@potentialtech.com> <20030829150151.GI19388@libertyrms.info> <3F4F7275.5030203@potentialtech.com> <20030829155401.GM19388@libertyrms.info> <28309.1062173915@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