postgresql/contrib/pg_stat_statements/expected
Tom Lane ce8d5fe0e2 plpgsql: optimize "SELECT simple-expression INTO var".
Previously, we always fed SELECT ... INTO to the SPI machinery.
While that works for all cases, it's a great deal slower than
the otherwise-equivalent "var := expression" if the expression
is "simple" and the INTO target is a single variable.  Users
coming from MSSQL or T_SQL are likely to be surprised by this;
they are used to writing SELECT ... INTO since there is no
"var := expression" syntax in those dialects.  Hence, check for
a simple expression and use the faster code path if possible.

(Here, "simple" means whatever exec_is_simple_query accepts,
which basically means "SELECT scalar-expression" without any
input tables, aggregates, qual clauses, etc.)

This optimization is not entirely transparent.  Notably, one of
the reasons it's faster is that the hooks that pg_stat_statements
uses aren't called in this path, so that the evaluated expression
no longer appears in pg_stat_statements output as it did before.
There may be some other minor behavioral changes too, although
I tried hard to make error reporting look the same.  Hopefully,
none of them are significant enough to not be acceptable as
routine changes in a PG major version.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Discussion: https://postgr.es/m/CAFj8pRDieSQOPDHD_svvR75875uRejS9cN87FoAC3iXMXS1saQ@mail.gmail.com
2026-03-20 18:23:45 -04:00
..
cleanup.out Refactor tests of pg_stat_statements for planning, utility and level tracking 2023-02-20 09:28:29 +09:00
cursors.out Show sizes of FETCH queries as constants in pg_stat_statements 2025-07-02 08:39:25 +09:00
dml.out Remove the query_id_squash_values GUC 2025-03-27 13:33:37 +01:00
entry_timestamp.out Track statement entry timestamp in contrib/pg_stat_statements 2023-11-27 02:52:17 +02:00
extended.out Make query jumbling also squash PARAM_EXTERN params 2025-06-24 19:36:32 +02:00
level_tracking.out plpgsql: optimize "SELECT simple-expression INTO var". 2026-03-20 18:23:45 -04:00
oldextversions.out pg_stat_statements: Add counters for generic and custom plans 2025-07-31 11:37:37 +09:00
parallel.out pg_stat_statements: Add columns to track parallel worker activity 2024-10-09 08:30:45 +09:00
plancache.out plpgsql: optimize "SELECT simple-expression INTO var". 2026-03-20 18:23:45 -04:00
planning.out Revert support for improved tracking of nested queries 2025-06-12 10:08:55 +09:00
privileges.out pg_stat_statements: Add regression test for privilege handling. 2024-07-24 20:54:51 +09:00
select.out Fix query jumbling with GROUP BY clauses 2026-01-14 08:44:12 +09:00
squashing.out pg_stat_statements: Rework test order 2026-01-21 07:47:38 +09:00
user_activity.out Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
utility.out Show sizes of FETCH queries as constants in pg_stat_statements 2025-07-02 08:39:25 +09:00
wal.out Show values of SET statements as constants in pg_stat_statements 2024-09-30 14:02:00 +09:00