Re: Problem: query becomes slow when calling a fast user defined function. - Mailing list pgsql-performance

From Tom Lane
Subject Re: Problem: query becomes slow when calling a fast user defined function.
Date
Msg-id 9625.1149561782@sss.pgh.pa.us
Whole thread Raw
In response to Problem: query becomes slow when calling a fast user defined function.  (Dan Libby <dan@libby.com>)
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Dan Libby
Date:
Subject: Problem: query becomes slow when calling a fast user defined function.
Next
From: "Andrus"
Date:
Subject: Re: How to force Postgres to use index on ILIKE