Commit 960d233d authored by Ahmad Sherif's avatar Ahmad Sherif

Merge branch 'sh-optimize-db-probe' into 'master'

Reduce CPU utilization of row count query

Closes #75

See merge request gitlab-org/gitlab-exporter!123
parents d8966ff5 864f6408
Pipeline #177688 passed with stage
in 2 minutes and 15 seconds
......@@ -175,6 +175,14 @@ module GitLab
def execute(query)
with_connection_pool do |conn|
conn.exec(query).map_types!(type_map_for_results(conn))
end
rescue PG::UndefinedTable, PG::UndefinedColumn
nil
end
def type_map_for_results(conn)
@type_map_for_results ||= begin
tm = PG::BasicTypeMapForResults.new(conn)
# Remove warning message:
......@@ -187,10 +195,8 @@ module GitLab
tm.add_coder(old_coder.dup.tap { |c| c.oid = value[:oid] })
end
conn.exec(query).map_types!(tm)
tm
end
rescue PG::UndefinedTable, PG::UndefinedColumn
nil
end
# Not private so I can test it without meta programming tricks
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment