Re: Proposal: Progressive explain

2025-04-05 Thread Rafael Thofehrn Castro
> True, although thinking about it more, they're not being sent to the > same place. auto_explain goes to the log, and this goes to a view. > What about something like this: > progressive_explain = on | off > progressive_explain_inteval = 5s > If progressive_explain is off, then we don't populate t

Re: Proposal: Progressive explain

2025-04-05 Thread Rafael Thofehrn Castro
> I haven't looked into the code yet, but when I ran below commands during > make installcheck, there was an error and an assertion failure Thanks for the report. I actually made a nasty mistake in the last patch after code refactoring, which is to not properly check that a QueryDesc is already be

Re: Proposal: Progressive explain

2025-04-01 Thread Rafael Thofehrn Castro
My bad, I mistakenly did the tests without assertion enabled in the last 2 days, so couldn't catch that Assertion failure. Was able to reproduce it, thanks. I guess when the code was designed we were not expecting to be doing explains in parallel workers. One comment is that this has nothing to d

Re: Proposal: Progressive explain

2025-03-31 Thread Rafael Thofehrn Castro
Hello again, > ERROR: could not attach to dynamic shared area In addition to that refactoring issue, the current patch had a race condition in pg_stat_progress_explain to access the DSA of a process running a query that gets aborted. While discussing with Robert we agreed that it would be wiser

Re: Proposal: Progressive explain

2025-03-29 Thread Rafael Thofehrn Castro
> (2) Merge progressive_explain = explain and progressive_explain = > analyze into a single value, progressive_explain = on. To tell which > is intended, just check progresive_explain_interval. If it's zero, > then there's no repeat, so we mean what you currently call > progressive_explain = explai

Re: Proposal: Progressive explain

2025-03-28 Thread Rafael Thofehrn Castro
> That is correct. Interval currently is only used when instrumentation > is enabled through progressive_explain = analyze. I guess there would still be a point in printing the plan on a regular interval when instrumentation is disabled. In that case the only thing we would see changing in the pla

Re: Proposal: Progressive explain

2025-03-28 Thread Rafael Thofehrn Castro
> I still have trouble understanding what that means. Is the interval > irrelevant except when progressive_explain = analyze? That is correct. Interval currently is only used when instrumentation is enabled through progressive_explain = analyze.

Re: Proposal: Progressive explain

2025-03-28 Thread Rafael Thofehrn Castro
> But having said that, I'm not quite sure I understand why you're > proposing (A) and (B1) as separate alternatives. Changing > progressive_explain to be a Boolean doesn't seem like it solves the > problem of needing to wrap ExecProcNode from a signal handler. The > only thing that seems to solve

Re: Proposal: Progressive explain

2025-03-27 Thread Rafael Thofehrn Castro
Thanks Robert. Very thorough analysis there. Things I don't comment on will be fixed without further discussion. > There is a comment in ExplainOnePlan() that says "Handle progressive > explain cleanup manually if enabled as it is not called as part of > ExecutorFinish," but standard_ExecutorFini

Re: Proposal: Progressive explain

2025-03-26 Thread Rafael Thofehrn Castro
> Suppose: > BEGIN; > SELECT 1; > SAVEPOINT bob; > progressively explain something that aborts > I think in this case we will call AbortSubTransaction(), not AbortTransaction(). Indeed. We need special treatment for subtransactions. There are 2 scenarios where AbortSubTransaction() will be called

Re: Proposal: Progressive explain

2025-03-26 Thread Rafael Thofehrn Castro
Sending a new version that includes the new explain_progressive.c file in meson.build. Rafael. v12-0001-Proposal-for-progressive-explains.patch Description: Binary data

Re: Proposal: Progressive explain

2025-03-25 Thread Rafael Thofehrn Castro
Hello Robert, Fixed most of the recommendations. Going over one at a time. > The documentation for the progressive_explain = { off | explain | > analyze } option seems like it should go into more detail about how > the "explain" and "analyze" values are different. I'm not 100% sure I > know the a

Re: Proposal: Progressive explain

2025-03-19 Thread Rafael Thofehrn Castro
Hi Robert, Thanks for sparing part of your precious time to look at the patch. I acknowledge it is a very complex one. Since you're going to take another look, providing some preliminary comments related to some of the implementation concerns. > I don't understand how this would be safe against i

Re: Proposal: Progressive explain

2025-03-19 Thread Rafael Thofehrn Castro
Sending a new version as rebase was required. Rafael. v10-0001-Proposal-for-progressive-explains.patch Description: Binary data

Re: Proposal: Progressive explain

2025-03-14 Thread Rafael Thofehrn Castro
Thanks for the valuable inputs Euler. Adjusted most of your recommendations. > I found a crash. It is simple to reproduce. Indeed, I failed to test plain EXPLAIN after the addition of the new GUC progressive_explain_min_duration. This is fixed. > You call this feature "progressive explain". My f

Re: Proposal: Progressive explain

2025-03-07 Thread Rafael Thofehrn Castro
> Implementation of the new GUC progressive_explain_min_duration was done > with > timeouts. The timeout callback function is used to initialize the > progressive > explain. > > There is a catch to this implementation. In thread > https://www.postgresql.org/message-id/flat/d68c3ae31672664876b22d2dc

Re: Proposal: Progressive explain

2025-02-18 Thread Rafael Thofehrn Castro
Fixed a corner case where pg_stat_progress_explain is looking at its own plan. Previous message in this thread contains all relevant implementation details of the last patch. On Tue, Feb 18, 2025 at 3:31 PM Rafael Thofehrn Castro wrote: > Hello all, > > Sending a new version of the p

Re: Proposal: Progressive explain

2025-02-18 Thread Rafael Thofehrn Castro
Hello all, Sending a new version of the patch that includes important changes addressing feedback provided by Greg and Tomas. So, including the previous version (v5) sent on Jan 29, these are the highlights of what has changed: - Progressive plan printed on regular interval defined by progressive

Re: Proposal: Progressive explain

2025-01-29 Thread Rafael Thofehrn Castro
Hi, Thanks for the valuable feedback Tomas. I am sending a new version of the patch that includes: - Changed instrumented plan printing based on timeouts instead of sampling. This works perfectly and benchmarks are promising. So new GUC progressive_explain_sampe_rate is removed. - Removed all par

Re: Proposal: Progressive explain

2025-01-07 Thread Rafael Thofehrn Castro
Sending rebased version to fix cfbot tests. v3-0001-Proposal-for-progressive-explains.patch Description: Binary data

Re: Proposal: Progressive explain

2024-12-31 Thread Rafael Thofehrn Castro
Thanks Greg, Sami and Jian for the feedback so far. > Maybe track_explain instead? In the spirit of track_activity. That was the original name, and all other GUCs were following the track_activity_* logic. Changed to the name of the feature after discussion with colleagues at EDB. This is definit

Proposal: Progressive explain

2024-12-29 Thread Rafael Thofehrn Castro
Hello community, CONTEXT: Back in October I presented the talk "Debugging active queries with mid-flight instrumented explain plans" at PGConf EU 2024 (recording: https://www.youtube.com/watch?v=6ahTb-7C05c) presenting an experimental feature that enables visualization of in progress EXPLAIN ANAL

Re: RFC: Logging plan of the running query

2023-12-06 Thread Rafael Thofehrn Castro
Hello hackers, Last Saturday I submitted a patch to the pgsql-hackers list with the title "Proposal: In-flight explain logging" with a patch proposing a feature very similar to the one being worked on in this thread. I should have done a better search in the commitfest before implementing somethin

Re: Proposal: In-flight explain logging

2023-12-02 Thread Rafael Thofehrn Castro
Hello Maciek, Thanks for pointing that out. They are indeed super similar. Before I wrote the patch I searched for "explain" related ones. I guess I should have performed a better search. Comparing the patches, there is one main difference: the existing patch prints only the plan without any inst

Proposal: In-flight explain logging

2023-12-02 Thread Rafael Thofehrn Castro
Hello hackers, # MOTIVATION My recent experiences with problematic queries in customers motivated me to write this patch proposing a new feature to enhance visibility on what active queries are doing. PostgreSQL already offers 2 very powerful tools for query troubleshooting: - EXPLAIN: gives us

Autovacuum worker spawning strategy

2022-07-19 Thread Rafael Thofehrn Castro
Hello all, While investigating a problem in a PG14 instance I noticed that autovacuum workers stop processing other databases when a database has a temporary table with age older than `autovacuum_freeze_max_age`. To test that I added a custom logline showing which database the about to spawned aut