Class: Timescaledb::Hypertable

Inherits:
ApplicationRecord show all
Defined in:
lib/timescaledb/hypertable.rb

Instance Method Summary collapse

Instance Method Details

#after_total_bytesObject



46
47
48
# File 'lib/timescaledb/hypertable.rb', line 46

def after_total_bytes
  compression_stats["after_compression_total_bytes"] || 0
end

#approximate_row_countObject



29
30
31
# File 'lib/timescaledb/hypertable.rb', line 29

def approximate_row_count
  struct_from("SELECT * FROM approximate_row_count('#{self.hypertable_name}')").first.approximate_row_count
end

#before_total_bytesObject



42
43
44
# File 'lib/timescaledb/hypertable.rb', line 42

def before_total_bytes
  compression_stats["before_compression_total_bytes"] || detailed_size.total_bytes
end

#chunks_detailed_sizeObject



25
26
27
# File 'lib/timescaledb/hypertable.rb', line 25

def chunks_detailed_size
  struct_from "SELECT * from chunks_detailed_size('#{self.hypertable_name}')"
end

#compression_statsObject



33
34
35
36
# File 'lib/timescaledb/hypertable.rb', line 33

def compression_stats
  @compression_stats ||=
    struct_from("SELECT * from hypertable_compression_stats('#{self.hypertable_name}')").first || {}
end

#detailed_sizeObject



38
39
40
# File 'lib/timescaledb/hypertable.rb', line 38

def detailed_size
  struct_from("SELECT * FROM hypertable_detailed_size('#{self.hypertable_name}')").first
end

#main_dimensionObject



21
22
23
# File 'lib/timescaledb/hypertable.rb', line 21

def main_dimension
  dimensions.find_by dimension_number: 1
end