Correct PostgreSQL metrics for dead tuples, with integration tests and refactoring #2474
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Larger version of #2468
pg_stat_user_tables
has a row for each table in the database, so selecting the first row of it results in "dead rows for a single random table". Calculating the sum overn_dead_tup
results in all dead rows instead.pg_stat_database
has only one row for each database, so the sum() overnumbackends
was harmless but unnecessary, so I removed that one.At least for PostgreSQL, there's a difference between
getObject(n, Long.class)
andgetLong(n)
. The former can only convert INT4 and INT8 (but not NUMERIC and DECIMAL) to Long, the latter converts all numeric types.sum(n_dead_tup)
is such a case where this matters, since its type is NUMERIC.I could understand if someone finds this too much of a change, so I created both MRs.