Module: ParadeDB::Diagnostics
- Defined in:
- lib/parade_db/diagnostics.rb
Class Method Summary collapse
- .index_segments(index, connection: ActiveRecord::Base.connection) ⇒ Object
- .indexes(connection: ActiveRecord::Base.connection) ⇒ Object
- .verify_all_indexes(schema_pattern: nil, index_pattern: nil, heapallindexed: false, sample_rate: nil, report_progress: false, on_error_stop: false, connection: ActiveRecord::Base.connection) ⇒ Object
- .verify_index(index, heapallindexed: false, sample_rate: nil, report_progress: false, verbose: false, on_error_stop: false, segment_ids: nil, connection: ActiveRecord::Base.connection) ⇒ Object
Class Method Details
.index_segments(index, connection: ActiveRecord::Base.connection) ⇒ Object
11 12 13 14 |
# File 'lib/parade_db/diagnostics.rb', line 11 def index_segments(index, connection: ActiveRecord::Base.connection) sql = "SELECT * FROM pdb.index_segments(#{connection.quote(index.to_s)}::regclass)" execute_table_function(connection, sql) end |
.indexes(connection: ActiveRecord::Base.connection) ⇒ Object
7 8 9 |
# File 'lib/parade_db/diagnostics.rb', line 7 def indexes(connection: ActiveRecord::Base.connection) execute_table_function(connection, "SELECT * FROM pdb.indexes()") end |
.verify_all_indexes(schema_pattern: nil, index_pattern: nil, heapallindexed: false, sample_rate: nil, report_progress: false, on_error_stop: false, connection: ActiveRecord::Base.connection) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/parade_db/diagnostics.rb', line 41 def verify_all_indexes( schema_pattern: nil, index_pattern: nil, heapallindexed: false, sample_rate: nil, report_progress: false, on_error_stop: false, connection: ActiveRecord::Base.connection ) params = [] params << "schema_pattern => #{connection.quote(schema_pattern)}" unless schema_pattern.nil? params << "index_pattern => #{connection.quote(index_pattern)}" unless index_pattern.nil? params << "heapallindexed => #{boolean_sql(heapallindexed)}" if heapallindexed params << "sample_rate => #{connection.quote(sample_rate)}::double precision" unless sample_rate.nil? params << "report_progress => #{boolean_sql(report_progress)}" if report_progress params << "on_error_stop => #{boolean_sql(on_error_stop)}" if on_error_stop sql = if params.empty? "SELECT * FROM pdb.verify_all_indexes()" else "SELECT * FROM pdb.verify_all_indexes(#{params.join(', ')})" end execute_table_function(connection, sql) end |
.verify_index(index, heapallindexed: false, sample_rate: nil, report_progress: false, verbose: false, on_error_stop: false, segment_ids: nil, connection: ActiveRecord::Base.connection) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/parade_db/diagnostics.rb', line 16 def verify_index( index, heapallindexed: false, sample_rate: nil, report_progress: false, verbose: false, on_error_stop: false, segment_ids: nil, connection: ActiveRecord::Base.connection ) sql = ["SELECT * FROM pdb.verify_index(#{connection.quote(index.to_s)}::regclass"] sql << ", heapallindexed => #{boolean_sql(heapallindexed)}" if heapallindexed sql << ", sample_rate => #{connection.quote(sample_rate)}::double precision" unless sample_rate.nil? sql << ", report_progress => #{boolean_sql(report_progress)}" if report_progress sql << ", verbose => #{boolean_sql(verbose)}" if verbose sql << ", on_error_stop => #{boolean_sql(on_error_stop)}" if on_error_stop unless segment_ids.nil? values = Array(segment_ids).map { |value| Integer(value) } sql << ", segment_ids => ARRAY[#{values.join(', ')}]::int[]" end sql << ")" execute_table_function(connection, sql.join) end |