pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dan Libby <dan@libby.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Problem: query becomes slow when calling a fast user defined function.
Date: Mon, 05 Jun 2006 22:43:02 -0400
Message-ID: <9625.1149561782@sss.pgh.pa.us> (raw)
In-Reply-To: <200606051804.00381.dan@libby.com>
References: <200606051804.00381.dan@libby.com>

Dan Libby <dan@libby.com> writes:
> Or failing that, I'd at least like to understand why the planner 
> is deciding not to use the category_lang index when the result 
> set is coming from a function instead of a "regular" table.

The planner defaults to assuming that set-returning functions return
1000 rows (as you can see in the EXPLAIN output).  A plan that would
win for a single returned row would lose badly at 1000 rows ...
and vice versa.  See the archives for various debates about how to
get a better estimate; it's not an easy problem.

			regards, tom lane



view thread (2+ messages)

Message-ID: <9625.1149561782@sss.pgh.pa.us>
Permalink:  ../9625.1149561782@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9625.1149561782@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, dan@libby.com
  Subject: Re: Problem: query becomes slow when calling a fast user defined function.
  In-Reply-To: <9625.1149561782@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