From: | "Kevin Grittner" <kgrittn(at)mail(dot)com> |
---|---|
To: | "Rodrigo Rosenfeld Rosas" <rr(dot)rosas(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: wrong search_path being used |
Date: | 2013-01-12 18:59:17 |
Message-ID: | 20130112185917.255770@gmx.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-01-12 19:29:38 | Re: wrong search_path being used |
Previous Message | Vitalii Tymchyshyn | 2013-01-12 12:42:41 | Re: [JDBC] BUG #7766: Running a DML statement that affects more than 4 billion rows results in an exception |