/usr/lib/ruby/vendor_ruby/sequel/extensions/pg_loose_count.rb is in ruby-sequel 4.15.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # The pg_loose_count extension looks at the table statistics
# in the PostgreSQL system tables to get a fast approximate
# count of the number of rows in a given table:
#
# DB.loose_count(:table) # => 123456
#
# It can also support schema qualified tables:
#
# DB.loose_count(:schema__table) # => 123456
#
# How accurate this count is depends on the number of rows
# added/deleted from the table since the last time it was
# analyzed.
#
# To load the extension into the database:
#
# DB.extension :pg_loose_count
#
module Sequel
module Postgres
module LooseCount
# Look at the table statistics for the given table to get
# an approximate count of the number of rows.
def loose_count(table)
from(:pg_class).where(:oid=>regclass_oid(table)).get(Sequel.cast(:reltuples, Integer))
end
end
end
Database.register_extension(:pg_loose_count, Postgres::LooseCount)
end
|