Class: PG::Connection
- Inherits:
-
Object
- Object
- PG::Connection
- Includes:
- MiniProfiler
- Defined in:
- lib/patches/db/pg/alias_method.rb,
lib/patches/db/pg/prepend.rb
Defined Under Namespace
Modules: MiniProfiler
Instance Method Summary collapse
- #async_exec(*args, &blk) ⇒ Object
- #async_exec_without_profiling ⇒ Object
- #exec(*args, &blk) ⇒ Object (also: #query)
- #exec_params(*args, &blk) ⇒ Object
- #exec_params_without_profiling ⇒ Object
- #exec_prepared(*args, &blk) ⇒ Object
- #exec_prepared_without_profiling ⇒ Object
- #exec_without_profiling ⇒ Object
- #prepare(*args, &blk) ⇒ Object
- #prepare_without_profiling ⇒ Object
- #send_query_prepared(*args, &blk) ⇒ Object
- #send_query_prepared_without_profiling ⇒ Object
Instance Method Details
#async_exec(*args, &blk) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/patches/db/pg/alias_method.rb', line 108 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 |
#async_exec_without_profiling ⇒ Object
32 |
# File 'lib/patches/db/pg/alias_method.rb', line 32 alias_method :async_exec_without_profiling, :async_exec |
#exec(*args, &blk) ⇒ Object Also known as: query
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/patches/db/pg/alias_method.rb', line 54 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 |
#exec_params(*args, &blk) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/patches/db/pg/alias_method.rb', line 67 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_params_without_profiling ⇒ Object
38 |
# File 'lib/patches/db/pg/alias_method.rb', line 38 alias_method :exec_params_without_profiling, :exec_params |
#exec_prepared(*args, &blk) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/patches/db/pg/alias_method.rb', line 80 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 ⇒ Object
33 |
# File 'lib/patches/db/pg/alias_method.rb', line 33 alias_method :exec_prepared_without_profiling, :exec_prepared |
#exec_without_profiling ⇒ Object
31 |
# File 'lib/patches/db/pg/alias_method.rb', line 31 alias_method :exec_without_profiling, :exec |
#prepare(*args, &blk) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/patches/db/pg/alias_method.rb', line 41 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 |
#prepare_without_profiling ⇒ Object
35 |
# File 'lib/patches/db/pg/alias_method.rb', line 35 alias_method :prepare_without_profiling, :prepare |
#send_query_prepared(*args, &blk) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/patches/db/pg/alias_method.rb', line 94 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 ⇒ Object
34 |
# File 'lib/patches/db/pg/alias_method.rb', line 34 alias_method :send_query_prepared_without_profiling, :send_query_prepared |