Closed csatnic-av closed 4 years ago
They're sorted by OID, which can vary between databases.
If you only want to compare tables, you can do this though:
# get pgmetrics output into "db.json"
pgmetrics -fjson -h HOST -U USER -w DB -odb.json
# extract list of tables
jq '.tables' db.json > tables.json
# extract list of tables, sorted by "name" field
jq '.tables' db.json | jq 'sort_by(.name)' > tables.json
# extract list of tables, sorted by schema_name, then name
jq '.tables' db.json | jq 'sort_by(.schema_name + .name)' > tables.json
jq is the jq utility that you should be able to install with apt/yum.
Does this help?
Yes ... thank you for the explanation and the workaround suggestion.
Version used: pgmetrics_1.9.2_linux_amd64 Command line parameters: pgmetrics -h HOST -U USER -w DB
I'm executing pgmetrics against two separate environments that run the same database with the same schema. I wanted to see a side-by-side comparison of the results. The bulk of the pgmetrics output is the detailed information listed about the tables in the database being inspected but the sort order for the tables varies wildly between the two environments.
What determines the sort order of the tables when pgmetrics exports that data? Can that sort order be controlled via any parameter so I can get both environments to list table details in the same order? I was not able to find any parameters that might control that.
Thank you.