pg_show_plans icon indicating copy to clipboard operation
pg_show_plans copied to clipboard

Add somekind of option to start disabled

Open kmoppel opened this issue 4 years ago • 1 comments

As such troubleshooting / debugging is not always used and has a small performance impact, would be nice if the extension could start in disabled mode and one could enable it when the need arises with pg_show_plans_enable(). An alternative is of course to disable the extension from "shared_preload_libraries", but this requires server restart which might not work for all.

kmoppel avatar Apr 03 '20 11:04 kmoppel

Hello, Here is a patch trying to answer this question by adding pg_show_plans.startup_enable GUC:

pg_show_plans.startup_enable.diff.txt

or https://github.com/legrandlegrand/pg_show_plans/pull/1

legrandlegrand avatar Apr 13 '20 10:04 legrandlegrand

Hello! I am the new maintainer.

It seems like currently we have a redundant variable, and none of the two give the desired functionality, i.e.:

static void
pgsp_ExecutorEnd(QueryDesc *queryDesc)
{
	/* Bypass the following steps if this pgsp_enable is set to false  */
	if (pgsp_enable)
	{
		/* Delete entry */
		SpinLockAcquire(&pgsp->elock);
		if (pgsp->is_enable)
		{
			SpinLockRelease(&pgsp->elock);
			delete_entry(MyProcPid);
		}
		else
			SpinLockRelease(&pgsp->elock);
	}

	if (prev_ExecutorEnd)
		prev_ExecutorEnd(queryDesc);
	else
		standard_ExecutorEnd(queryDesc);
}

The execution occurs iff both *_enable variables are set to true. I just cannot find the difference it makes having those two in the different states.

I will try to refactor this functionality a little bit.

kovmir avatar Jan 24 '23 19:01 kovmir

Alright, I got it. GUC variable disables the extension locally, and shared structure variable disables the extension globally (for all clients).

kovmir avatar Jan 26 '23 13:01 kovmir