Skip to content

Commit

Permalink
Fixed error with auto_explain - fixes #48
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jan 6, 2024
1 parent e3ea177 commit 0b9fedc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.5.2 (unreleased)

- Switched to `GENERIC_PLAN` for Postgres 16
- Fixed error with `auto_explain`
- Fixed warning with Ruby 3.3

## 0.5.1 (2023-05-27)
Expand Down
2 changes: 1 addition & 1 deletion lib/dexter/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def create_hypothetical_indexes(queries)

# get initial costs for queries
calculate_plan(queries)
explainable_queries = queries.select { |q| q.explainable? && q.high_cost? }
explainable_queries = queries.select { |q| q.plans.any? && q.high_cost? }

# filter tables for performance
tables = Set.new(explainable_queries.flat_map(&:tables))
Expand Down
2 changes: 1 addition & 1 deletion lib/dexter/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def tree
end

def explainable?
plans.any?
plans.size >= 3
end

def costs
Expand Down

0 comments on commit 0b9fedc

Please sign in to comment.