Skip to content

Fix get_table_stats row counts - #1

Open
pbourdon71 wants to merge 1 commit into
caleb-mabry:mainfrom
pbourdon71:fix-table-stats-row-count
Open

Fix get_table_stats row counts#1
pbourdon71 wants to merge 1 commit into
caleb-mabry:mainfrom
pbourdon71:fix-table-stats-row-count

Conversation

@pbourdon71

Copy link
Copy Markdown

Summary

get_table_stats was reporting cumulative row activity instead of live row counts. The implementation used n_tup_ins + n_tup_upd + n_tup_del, which grows with churn and diverges from both COUNT(*) and n_live_tup.

This changes row_count to use COALESCE(n_live_tup, 0)::bigint in both getTableStatsTool queries and tightens the integration test to assert the expected fixture row count.

Validation

  • npm run build
  • npm test -- --runTestsByPath tests/integration/container.test.ts

Notes

I reproduced the bug against a live PostgreSQL database before patching:

  • exact COUNT(*) on players: 34475
  • pg_stat_user_tables.n_live_tup: 34475
  • get_table_stats row_count before fix: 365631

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant