debian-mirror-gitlab/lib/gitlab/database/pg_class.rb

24 lines
491 B
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
module Gitlab
module Database
2022-01-26 12:08:38 +05:30
class PgClass < SharedModel
2021-04-29 21:17:54 +05:30
self.table_name = 'pg_class'
def self.for_table(relname)
joins("LEFT JOIN pg_stat_user_tables ON pg_stat_user_tables.relid = pg_class.oid")
.where('schemaname = current_schema()')
.find_by(relname: relname)
end
def cardinality_estimate
tuples = reltuples.to_i
return if tuples < 1
tuples
end
end
end
end