powa-team / powa

PostgreSQL Workload Analyzer
http://powa.readthedocs.io/
PostgreSQL License
768 stars 57 forks source link

Enhancement : Take into account application_name #149

Closed chmanu closed 3 years ago

chmanu commented 3 years ago

It will be interesting to filter on application_name to list the queries. Two use case :

We could consider a combo box beside the field to filter SQL.

Regards.

rjuju commented 3 years ago

Hello @chmanu,

I agree that the goals you're showing are quite worthwhile, however I'm not sure that application_name is the right way to go. Indeed, the root source for all data is pg_stat_statements, which only used database, user and query identifier to uniquely identify a query. It means that for any application consuming this data, like powa, the application_name isn't available anymore.

Adding application_name to pg_stat_statements is probably also not a good idea, as it could easily amplify the number of distinct entries pg_stat_statements sees. This is not something wanted, as pg_stat_statements adds a dramatic overhead when you have a workload leading to frequent entry evictions.

So this is unfortunately not an ideal answer, but your best option is to use dedicated postgres roles for your various usage, so you can eventually filter them out of pg_stat_statements and similar extensions. That would also be only part of the solution, as for now powa-web is entirely ignoring roles, as no-one expressed that need yet. But that's something fixable, and I'd be happy to add some UI capability regarding the roles if that could help your usecase.