Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#727 add explain plan of sql requests for Postgresql 16 or later #1223

Merged
merged 3 commits into from
May 27, 2024

Conversation

evernat
Copy link
Member

@evernat evernat commented May 21, 2024

issue #727,
for reference, https://www.cybertec-postgresql.com/en/explain-generic-plan-postgresql-16/

In pgAdmin 4, generic explain plan works well, for example:

explain (generic_plan) select 'dummy' where $1 = $2

Unfortunately, after testing the code of this pull request with Postgresql 16.3 and jdbc driver 42.7.3, in the monitoring detail page of sql requests which includes ? parameters, there is an error coming from the database and so no explain plan:

org.postgresql.util.PSQLException: ERREUR: Bind message supplies 0 parameters, but prepared statement "" requires 2
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2412)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:371)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:502)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:419)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:341)
        at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:326)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:302)
        at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:251)
	...
        at net.bull.javamelody.internal.model.DatabaseInformations.explainPlanFor(DatabaseInformations.java:374)
        at net.bull.javamelody.internal.web.html.HtmlCounterRequestGraphReport.writeSqlRequestExplainPlan(HtmlCounterRequestGraphReport.java:191)
        at net.bull.javamelody.internal.web.html.HtmlCounterRequestGraphReport.writeRequestAndGraphDetail(HtmlCounterRequestGraphReport.java:124)
        at net.bull.javamelody.internal.web.html.HtmlReport.writeRequestAndGraphDetail(HtmlReport.java:254)
        at net.bull.javamelody.internal.web.HtmlController.doRequestGraphAndDetail(HtmlController.java:150)
	...

@evernat
Copy link
Member Author

evernat commented May 21, 2024

For that error, I do not see a way from jdbc api so that Postgresql does not require parameters in generic explain plan, like it does from pgAdmin4.

@evernat
Copy link
Member Author

evernat commented May 27, 2024

I have finally found a way using internal classes of the postgresql driver 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant