Re: wrong search_path being used - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: wrong search_path being used
Date
Msg-id 20130112185917.255770@gmx.com
Whole thread Raw
In response to wrong search_path being used  (Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>)
Responses Re: wrong search_path being used
List pgsql-bugs
Rodrigo Rosenfeld Rosas wrote:

> I'm curious though. Why wouldn't this behavior be considered a
> bug? Is there any link to previous discussions about this subject
> that I could read?

A plpgsql function generates a plan on initial execution which
chooses which particular tables are used. On subsequent executions
that saves the overhead of parsing out the statement and looking up
the table and its details, which can help performance quite a bit.
If you want to have source code evaluated each time the function is
called, you should use the EXECUTE statement within your function
body, which will force parsing and path resolution of the statement
for each execution. That should give you the behavior you want,
with some cost in performance.

To try to get your function code to work as you expect, the
language would essentially need to identify which statements could
be pre-planned, and which would needed to be treated as raw source
on each execution. That would be tricky to implement, and would
itself have some run-time cost. At this point we've put the burden
on the programmer to identify this at the time the code is written,
rather than adding run-time expense.

-Kevin

pgsql-bugs by date:

Previous
From: Vitalii Tymchyshyn
Date:
Subject: Re: [JDBC] BUG #7766: Running a DML statement that affects more than 4 billion rows results in an exception
Next
From: Tom Lane
Date:
Subject: Re: wrong search_path being used