From: Michael Fuhr <mike@fuhr.org>
To: Magno Leite <magnomilk@yahoo.com.br>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #1797: Problem using Limit in a function, seqscan
Date: Fri, 29 Jul 2005 08:00:38 -0600
Message-ID: <20050729140038.GA83653@winnie.fuhr.org> (raw)
In-Reply-To: <20050729125245.1166CF0B14@svr2.postgresql.org>
References: <20050729125245.1166CF0B14@svr2.postgresql.org>
On Fri, Jul 29, 2005 at 01:52:45PM +0100, Magno Leite wrote:
> I looked for about this problem in BUG REPORT but I can't find. This is my
> problem, when I try to use limit in a function, the Postgre doesn't use my
> index, then it use sequencial scan. What is the problem ?
Without more information we can only guess, but if you're using
PL/pgSQL then a cached query plan might be responsible. Here's an
excerpt from the PREPARE documentation:
In some situations, the query plan produced for a prepared
statement will be inferior to the query plan that would have
been chosen if the statement had been submitted and executed
normally. This is because when the statement is planned and
the planner attempts to determine the optimal query plan, the
actual values of any parameters specified in the statement are
unavailable. PostgreSQL collects statistics on the distribution
of data in the table, and can use constant values in a statement
to make guesses about the likely result of executing the
statement. Since this data is unavailable when planning prepared
statements with parameters, the chosen plan may be suboptimal.
If you'd like us to take a closer look, then please post a self-
contained example, i.e., all SQL statements that somebody could
load into an empty database to reproduce the behavior you're seeing.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
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: mike@fuhr.org, magnomilk@yahoo.com.br, pgsql-bugs@postgresql.org
Subject: Re: BUG #1797: Problem using Limit in a function, seqscan
In-Reply-To: <20050729140038.GA83653@winnie.fuhr.org>
* 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