From: m-pg@8d.no
To: pgsql-bugs@postgresql.org
Subject: BUG #7651: Superfluous calls to functions used for indexing
Date: Sun, 11 Nov 2012 15:45:54 +0000
Message-ID: <E1TXZjO-0000S2-1e@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 7651
Logged by: Morten Minde Neergaard
Email address: m-pg@8d.no
PostgreSQL version: 9.1.6
Operating system: Debian Wheezy
Description:
Bug: When making an index over a function, then selecting a result that does
not contain the function call (but orders on it), Superfluous function calls
are made. This possibly because the plan creates a projection containing the
function value.
Steps to reproduce:
1. Create a function that gives you a immutable reply. In my real function,
runtime is several ms. The SQL script referred to at the bottom contains a
more minimal, if horribly ugly, example. It prints a NOTICE every time it is
run.
2. Use this function to create an index. In the attached example, this
prints one NOTICE for each row, as expected.
3. Select a small number of rows using e.g. ORDER BY and LIMIT. This returns
correctly, but takes longer than expected to execute. The NOTICE is printed
five times, even though the function should not need be called.
I have made a minimal script reproducing this, and run it with simple test
data. All URLs below.
SQL script: http://xim.akuma.no/psql_bug/psql_bug.txt
Script output: http://xim.akuma.no/psql_bug/psql_bug_log.txt
Data for test: http://xim.akuma.no/psql_bug/file_containing_ints
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-bugs@postgresql.org
Cc: m-pg@8d.no
Subject: Re: BUG #7651: Superfluous calls to functions used for indexing
In-Reply-To: <E1TXZjO-0000S2-1e@wrigleys.postgresql.org>
References: <E1TXZjO-0000S2-1e@wrigleys.postgresql.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