BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: pavlicek(dot)david(at)gmail(dot)com
Subject: BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions
Date: 2024-11-07 09:10:31
Message-ID: 18694-7b7b34afc52db448@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18694
Logged by: David Pavlíček
Email address: pavlicek(dot)david(at)gmail(dot)com
PostgreSQL version: 13.13
Operating system: Linux
Description:

Recently, I encountered a issue where execution plans for SQL queries within
plpgsql functions differed significantly in a pooled database session, even
though after each call the session state was cleared using the DISCARD ALL
command. As per documentation, DISCARD ALL resets the session to its initial
state, which is probably not true for plpgsql exec counters. When
considering that execution plans for internal queries is generated based on
number of execution within single session (custom vs generic), this can have
huge impact on how the functions behaves in combination with connection
pooler, whether central one like pgbouncer or those built into client
libraries. In my opinion, the DISCARD ALL command should reset the internal
execution counters of plpgsql functions.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-11-07 10:02:01 BUG #18696: Compatibility Query for Updating zlib1.dll in PostgreSQL 10.2 to Address Security Vulnerabilities
Previous Message Aleksander Alekseev 2024-11-07 08:32:30 TimestampTz->Text->TimestampTz casting fails with DateStyle 'Postgres'