Skip to content

Commit

Permalink
chore: Use system.parts table to get count of rows. much cheaper
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech committed Nov 17, 2023
1 parent ecbdd9c commit 0cef06e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions posthog/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,8 @@ def clickhouse_row_count():
)
for table in CLICKHOUSE_TABLES:
try:
QUERY = (
"""select count(1) freq from {table} where _timestamp >= toStartOfDay(date_sub(DAY, 2, now()));"""
)
QUERY = """SELECT sum(rows) rows from system.parts
WHERE table = '{table}' and is_active;"""
query = QUERY.format(table=table)
rows = sync_execute(query)[0][0]
row_count_gauge.labels(table_name=table).set(rows)
Expand Down

0 comments on commit 0cef06e

Please sign in to comment.