pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions
4+ messages / 4 participants
[nested] [flat]
* BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions
@ 2024-11-07 09:10 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 4+ messages in thread
From: PG Bug reporting form @ 2024-11-07 09:10 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: pavlicek.david@gmail.com
The following bug has been logged on the website:
Bug reference: 18694
Logged by: David Pavlíček
Email address: pavlicek.david@gmail.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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions
@ 2024-11-07 13:38 David G. Johnston <david.g.johnston@gmail.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 4+ messages in thread
From: David G. Johnston @ 2024-11-07 13:38 UTC (permalink / raw)
To: pavlicek.david@gmail.com <pavlicek.david@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Thursday, November 7, 2024, PG Bug reporting form <noreply@postgresql.org>
wrote:
> The following bug has been logged on the website:
>
> Bug reference: 18694
> Logged by: David Pavlíček
> Email address: pavlicek.david@gmail.com
> PostgreSQL version: 13.13
> Operating system: Linux
> Description:
>
> In my opinion, the DISCARD ALL command should reset the internal
> execution counters of plpgsql functions.
>
>
To my knowledge there is no user-exposed way to reset those counters. Thus
discard all cannot reset them. It is a missing feature, not a bug. One
that I agree makes sense to add.
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions
@ 2024-11-08 07:51 David Pavlíček <pavlicek.david@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: David Pavlíček @ 2024-11-08 07:51 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
In my opinion it is a bug. Documentation clearly states that DISCARD ALL
"resets the session to its initial state", which is not true. So either
it's a documentation error and DISCARD ALL isn't meant to completely reset
the state, or it's meant to completely reset the state and then it's a bug
in its implementation (whether it is a missing feature or bug in existing
one). I agree that Implementing a new user-exposed command and then calling
it within DISCARD ALL is probably the right solution to the problem.
David P.
čt 7. 11. 2024 v 14:38 odesílatel David G. Johnston <
david.g.johnston@gmail.com> napsal:
> On Thursday, November 7, 2024, PG Bug reporting form <
> noreply@postgresql.org> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference: 18694
>> Logged by: David Pavlíček
>> Email address: pavlicek.david@gmail.com
>> PostgreSQL version: 13.13
>> Operating system: Linux
>> Description:
>>
>> In my opinion, the DISCARD ALL command should reset the internal
>> execution counters of plpgsql functions.
>>
>>
> To my knowledge there is no user-exposed way to reset those counters.
> Thus discard all cannot reset them. It is a missing feature, not a bug.
> One that I agree makes sense to add.
>
> David J.
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions
@ 2024-11-08 10:38 Pavel Stehule <pavel.stehule@gmail.com>
parent: David Pavlíček <pavlicek.david@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Pavel Stehule @ 2024-11-08 10:38 UTC (permalink / raw)
To: David Pavlíček <pavlicek.david@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hi
pá 8. 11. 2024 v 10:27 odesílatel David Pavlíček <pavlicek.david@gmail.com>
napsal:
> In my opinion it is a bug. Documentation clearly states that DISCARD ALL
> "resets the session to its initial state", which is not true. So either
> it's a documentation error and DISCARD ALL isn't meant to completely reset
> the state, or it's meant to completely reset the state and then it's a bug
> in its implementation (whether it is a missing feature or bug in existing
> one). I agree that Implementing a new user-exposed command and then calling
> it within DISCARD ALL is probably the right solution to the problem.
>
Please, don't send the top posting style
https://en.wikipedia.org/wiki/Posting_style in this mailing list.
Generally inside Postgres are more internal counters that ensure some
unique numbers or names, that are not reset by DISCARD ALL. DISCARD ALL is
synonym for
CLOSE ALL;
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD TEMP;
DISCARD SEQUENCES;
other features not promised. It is hard to say if unique numbers should be
resetted too. There are two reasons - possibly performance impact, and it
can be hard to implement it. There is not any list of these counters (some
counters are inside extensions). It can be better explained in doc.
Regards
Pavel
>
> David P.
>
> čt 7. 11. 2024 v 14:38 odesílatel David G. Johnston <
> david.g.johnston@gmail.com> napsal:
>
>> On Thursday, November 7, 2024, PG Bug reporting form <
>> noreply@postgresql.org> wrote:
>>
>>> The following bug has been logged on the website:
>>>
>>> Bug reference: 18694
>>> Logged by: David Pavlíček
>>> Email address: pavlicek.david@gmail.com
>>> PostgreSQL version: 13.13
>>> Operating system: Linux
>>> Description:
>>>
>>> In my opinion, the DISCARD ALL command should reset the internal
>>> execution counters of plpgsql functions.
>>>
>>>
>> To my knowledge there is no user-exposed way to reset those counters.
>> Thus discard all cannot reset them. It is a missing feature, not a bug.
>> One that I agree makes sense to add.
>>
>> David J.
>>
>>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-11-08 10:38 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-07 09:10 BUG #18694: DISCARD ALL does not reset execution counters for plpgsql functions PG Bug reporting form <noreply@postgresql.org>
2024-11-07 13:38 ` David G. Johnston <david.g.johnston@gmail.com>
2024-11-08 07:51 ` David Pavlíček <pavlicek.david@gmail.com>
2024-11-08 10:38 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox