libp2p/hydra-booster

Use fast approximate queries to Postgres for metrics collection

petar opened this issue · 0 comments

petar commented

Currently, metrics collection uses exact counting (SELET COUNT), which is slow and expensive and is found to interfere with useful payload queries to the database. Consider using an approximate count query, provided by Postgres. E.g.

  SELECT
  (reltuples/relpages) * (
    pg_relation_size('records') /
    (current_setting('block_size')::integer)
  )
  FROM pg_class where relname = 'records';