summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-11-22 19:33:34 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2025-11-22 19:33:34 -0500
commitb140c8d7a3f3a5de4e4cc4a0b52909aa13060d4c (patch)
tree69154d2eb059b475ca9d94f6caa80e60d012c9e3 /doc/src
parentc0bc9af15197e3604a6ec205a7485de21b0b21af (diff)
Add SupportRequestInlineInFrom planner support request.
This request allows a support function to replace a function call appearing in FROM (typically a set-returning function) with an equivalent SELECT subquery. The subquery will then be subject to the planner's usual optimizations, potentially allowing a much better plan to be generated. While the planner has long done this automatically for simple SQL-language functions, it's now possible for extensions to do it for functions outside that group. Notably, this could be useful for functions that are presently implemented in PL/pgSQL and work by generating and then EXECUTE'ing a SQL query. Author: Paul A Jungwirth <pj@illuminatedcomputing.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/09de6afa-c33d-4d94-a5cb-afc6cea0d2bb@illuminatedcomputing.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/xfunc.sgml25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 55a99c0ff34..537ee6fa254 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -4160,6 +4160,31 @@ supportfn(internal) returns internal
</para>
<para>
+ <literal>SupportRequestSimplify</literal> is not used
+ for <link linkend="queries-tablefunctions">set-returning
+ functions</link>. Instead, support functions can implement
+ the <literal>SupportRequestInlineInFrom</literal> request to expand
+ function calls appearing in the <literal>FROM</literal> clause of a
+ query. (It's also allowed to support this request for
+ non-set-returning functions, although
+ typically <literal>SupportRequestSimplify</literal> would serve as
+ well.) For this request type, a successful result must be
+ a <literal>SELECT</literal> Query tree, which will replace
+ the <literal>FROM</literal> item as though a sub-select had been
+ written instead. The Query tree must appear as it would after parse
+ analysis and rewrite processing. One way to ensure that that's true
+ is to build a SQL string then feed it
+ through <function>pg_parse_query</function>
+ and <function>pg_analyze_and_rewrite</function>, or related
+ functions. <literal>PARAM_EXTERN</literal> <structname>Param</structname>
+ nodes can appear within the Query to represent the function's
+ arguments; they will be replaced by the actual argument expressions.
+ As with <literal>SupportRequestSimplify</literal>, it is the support
+ function's responsibility that the replacement Query be equivalent to
+ normal execution of the target function.
+ </para>
+
+ <para>
For target functions that return <type>boolean</type>, it is often useful to estimate
the fraction of rows that will be selected by a <literal>WHERE</literal> clause using that
function. This can be done by a support function that implements