lib/dexter/indexer.rb in pgdexter-0.5.0 vs lib/dexter/indexer.rb in pgdexter-0.5.1

- old
+ new

@@ -195,15 +195,21 @@ # since every set of multi-column indexes are expensive # try to parse out columns possible_columns = Set.new explainable_queries.each do |query| log "Finding columns: #{query.statement}" if @log_level == "debug3" - find_columns(query.tree).each do |col| - last_col = col["fields"].last - if last_col["String"] - possible_columns << last_col["String"]["sval"] + begin + find_columns(query.tree).each do |col| + last_col = col["fields"].last + if last_col["String"] + possible_columns << last_col["String"]["sval"] + end end + rescue JSON::NestingError + if @log_level.start_with?("debug") + log colorize("ERROR: Cannot get columns", :red) + end end end # create hypothetical indexes # use all columns in tables from views @@ -224,10 +230,10 @@ candidates end def find_columns(plan) - plan = JSON.parse(plan.to_json) + plan = JSON.parse(plan.to_json, max_nesting: 1000) find_by_key(plan, "ColumnRef") end def find_indexes(plan) find_by_key(plan, "Index Name")