Class: Timescaledb::Hypertable

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

Instance Method Summary collapse

Instance Method Details

#after_total_bytesObject



48
49
50
# File 'lib/timescaledb/hypertable.rb', line 48

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

#approximate_row_countObject



31
32
33
# File 'lib/timescaledb/hypertable.rb', line 31

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

#before_total_bytesObject



44
45
46
# File 'lib/timescaledb/hypertable.rb', line 44

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

#chunks_detailed_sizeObject



27
28
29
# File 'lib/timescaledb/hypertable.rb', line 27

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

#compression_statsObject



35
36
37
38
# File 'lib/timescaledb/hypertable.rb', line 35

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

#detailed_sizeObject



40
41
42
# File 'lib/timescaledb/hypertable.rb', line 40

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

#main_dimensionObject



23
24
25
# File 'lib/timescaledb/hypertable.rb', line 23

def main_dimension
  dimensions.find_by dimension_number: 1
end