Skip to content

Conversation

@cherts
Copy link

@cherts cherts commented Oct 10, 2024

The database may have a non-standard search_path (standard: "$user", public) that does not include the public schema. In this case, you need to discovery which schema the pg_stat_statements extension is installed in and use the full name schema.pg_stat_statements in the query.

@mdevan
Copy link
Contributor

mdevan commented Oct 11, 2024

Thanks for the PR.

In general, the information about which schema an extension is installed in seems to be useful enough to be included the pgmetrics output.

I'm thinking it might be better to collect the name of the schema also during getExtensions(), store it in a new field in pgmetrics.Extension, and use it later in the getStatements*() functions.

The new query in getExtensions can be:

SELECT e.name AS name, current_database(),
  COALESCE(e.default_version, ''),
  x.extversion,
  COALESCE(e.comment, ''),
  x.extnamespace::regnamespace
FROM pg_available_extensions() e(name, default_version, comment)
  LEFT JOIN pg_extension x ON e.name = x.extname
WHERE x.extversion IS NOT NULL
ORDER BY name ASC

What are your thoughts?

@cherts
Copy link
Author

cherts commented Oct 11, 2024

Hi

I think this is a good idea, I'll try to improve my PR

…t in a new field in pgmetrics.Extension.SchemaName
@cherts
Copy link
Author

cherts commented Oct 11, 2024

@mdevan please, review my changes)

@mdevan mdevan merged commit 975c98a into rapidloop:master Oct 11, 2024
@mdevan
Copy link
Contributor

mdevan commented Oct 11, 2024

Thanks for the update. Couple more minor changes are required for consistency with how we add new fields and modify queries, but I think I'll do that myself after merging this in.

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.

2 participants