pawurb / ruby-pg-extras

Ruby PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.
MIT License
137 stars 11 forks source link

Customizing queries, ignore schemas #10

Closed darkhelmet closed 2 years ago

darkhelmet commented 2 years ago

Didn't really have a better title for this but...

I've started building out a feature in our application that uses multiple schemas. This means, that when I later use rails-pg-extras and RailsPGExtras.index_usage I get indexes for materialized views I've created in this other schema. Since the views I'm creating have the same name as tables in the public schema, I'll get duplicate entries for users, for example. The output doesn't include the schema name so I don't get that information and can't pick the correct version of the index I care about.

Basically, the end goal is I want to include only the public schema for index_usage, and basically anything else that would include things in multiple schemas. So either I need to be able to customize the query, or get more information from the query so I can ignore it later on, or something else. I'm open to suggestions. I could fork the gem, but this seems like something that could be useful for other people.

Ideas? I can make a PR if there's some direction you think would be best.

pawurb commented 2 years ago

Hi, thanks for a proposal. Yeah, I think it will be a beneficial change. Can you submit a PR? I think the simplest way to implement it would be to make schemaname configurable using a query args and leave the default value at public. You'd need to add correct DEFAULT_ARGS values for all the queries that use schema.