What about having helpers for indexes analysis?
Hello,
First of all, thanks for your gem! That's very useful.
I developed some wrapper to pg_query to ease the parsing of pg_query tree for indexes. Do you think that would be valuable to include that in pg_query?
Example:
my_indexes = IndexDefinition.list(connection)
my_indexes = IndexDefinition.list(connection, pattern: '%deleted_at IS NULL%')
my_indexes = IndexDefinition.list(connection, table_name: 'accounts')
On IndexDefinition class we would have such methods:
#name#table_name#definition#composite?#indexed_columns#partial_index?#where_clause
If you think it's interesting I could prepare a PR for that. If not, I would probably create a dedicated project :)
First of all, thanks for your gem! That's very useful.
Glad to see you find it useful!
I developed some wrapper to pg_query to ease the parsing of pg_query tree for indexes. Do you think that would be valuable to include that in pg_query?
Do I understand correctly that the aim of the methods is to find potential index elements in a given parse tree?
Assuming yes, I think that could certainly be useful, so +1 to opening a PR on pg_query.
Just to note, we have something similar inside in pganalyze (though we actually do it based on a version of a generic plan tree), but I think it'd be helpful to have something simple directly in pg_query as well.
Out of curiosity, how are you handling unqualified column names? (I imagine ideally this would take a table definition, so you know which column relates to which table?)