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