lib/dexter/indexer.rb in pgdexter-0.3.0 vs lib/dexter/indexer.rb in pgdexter-0.3.1
- old
+ new
@@ -128,21 +128,25 @@
end
end
def calculate_plan(queries)
queries.each do |query|
+ if @log_explain
+ puts "Explaining query"
+ puts
+ end
begin
query.plans << plan(query.statement)
if @log_explain
- log "Explaining query"
- puts
# Pass format to prevent ANALYZE
puts execute("EXPLAIN (FORMAT TEXT) #{safe_statement(query.statement)}").map { |r| r["QUERY PLAN"] }.join("\n")
- puts
end
- rescue PG::Error
- # do nothing
+ rescue PG::Error => e
+ if @log_explain
+ log e.message
+ end
end
+ puts if @log_explain
end
end
def create_hypothetical_indexes(queries, tables)
candidates = {}