class PG::Connection

Public Instance Methods

async_exec(*args, &blk) click to toggle source
# File lib/patches/db/pg.rb, line 109
def async_exec(*args, &blk)
  return async_exec_without_profiling(*args, &blk) unless SqlPatches.should_measure?

  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = exec_without_profiling(*args, &blk)
  elapsed_time = SqlPatches.elapsed_time(start)
  record       = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
  result.instance_variable_set("@miniprofiler_sql_id", record) if result

  result
end
Also aliased as: async_exec_without_profiling
async_exec_without_profiling(*args, &blk)
Alias for: async_exec
exec(*args, &blk) click to toggle source
# File lib/patches/db/pg.rb, line 55
def exec(*args, &blk)
  return exec_without_profiling(*args, &blk) unless SqlPatches.should_measure?

  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = exec_without_profiling(*args, &blk)
  elapsed_time = SqlPatches.elapsed_time(start)
  record       = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
  result.instance_variable_set("@miniprofiler_sql_id", record) if result

  result
end
Also aliased as: exec_without_profiling, query
exec_params(*args, &blk) click to toggle source
# File lib/patches/db/pg.rb, line 68
def exec_params(*args, &blk)
  return exec_params_without_profiling(*args, &blk) unless SqlPatches.should_measure?

  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = exec_params_without_profiling(*args, &blk)
  elapsed_time = SqlPatches.elapsed_time(start)
  record       = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
  result.instance_variable_set("@miniprofiler_sql_id", record) if result

  result
end
exec_prepared(*args, &blk) click to toggle source
# File lib/patches/db/pg.rb, line 81
def exec_prepared(*args, &blk)
  return exec_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?

  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = exec_prepared_without_profiling(*args, &blk)
  elapsed_time = SqlPatches.elapsed_time(start)
  mapped       = args[0]
  mapped       = @prepare_map[mapped] || args[0] if @prepare_map
  record       = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time)
  result.instance_variable_set("@miniprofiler_sql_id", record) if result

  result
end
exec_prepared_without_profiling(*args, &blk)
Alias for: exec_prepared
exec_without_profiling(*args, &blk)
Alias for: exec
prepare(*args, &blk) click to toggle source
# File lib/patches/db/pg.rb, line 42
def prepare(*args, &blk)
  # we have no choice but to do this here,
  # if we do the check for profiling first, our cache may miss critical stuff

  @prepare_map ||= {}
  @prepare_map[args[0]] = args[1]
  # dont leak more than 10k ever
  @prepare_map = {} if @prepare_map.length > 1000

  return prepare_without_profiling(*args, &blk) unless SqlPatches.should_measure?
  prepare_without_profiling(*args, &blk)
end
Also aliased as: prepare_without_profiling
prepare_without_profiling(*args, &blk)
Alias for: prepare
query(*args, &blk)
Alias for: exec
send_query_prepared(*args, &blk) click to toggle source
# File lib/patches/db/pg.rb, line 95
def send_query_prepared(*args, &blk)
  return send_query_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?

  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = send_query_prepared_without_profiling(*args, &blk)
  elapsed_time = SqlPatches.elapsed_time(start)
  mapped       = args[0]
  mapped       = @prepare_map[mapped] || args[0] if @prepare_map
  record       = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time)
  result.instance_variable_set("@miniprofiler_sql_id", record) if result

  result
end
send_query_prepared_without_profiling(*args, &blk)
Alias for: send_query_prepared