-
Notifications
You must be signed in to change notification settings - Fork 249
Refine Inspect queries and add CSVQ support for rule parsing #3595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
80c020e
to
e266458
Compare
inspectTotalIndexSizeCmd = &cobra.Command{ | ||
Use: "total-index-size", | ||
Short: "Show total size of all indexes", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return total_index_size.Run(cmd.Context(), flags.DbConfig, afero.NewOsFs()) | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better hide deprecated commands instead so it doesn't break existing users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we hide these typically? Do you return a recommendation of the new command or call the new command and print a deprecation warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 171 in b2ac658
Deprecated: "use \"db diff --use-migra --linked\" instead.\n", |
Depends on the situation. I think in this case, it is fine to invoke new command and print warning.
If there's no close substitute, then we need to keep the old code around as well.
@@ -38,12 +38,12 @@ WITH constants AS ( | |||
JOIN pg_class c2 ON c2.oid = i.indexrelid | |||
) | |||
SELECT | |||
type, schemaname, object_name, bloat, pg_size_pretty(raw_waste) as waste | |||
type, name, bloat, pg_size_pretty(raw_waste) as waste | |||
FROM | |||
(SELECT | |||
'table' as type, | |||
schemaname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line seems redundant now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how so? do you mean to just select * or because of something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I see you've combined it with object_name. And it doesn't appear in the result struct.
But I haven't tried it out so might be wrong.
array_to_string(rolconfig, ',', '*') as custom_config | ||
FROM | ||
pg_roles | ||
ORDER BY 3 DESC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why order by connection_limit instead of role_name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to order by the users with changed configs first but the assumption of "higher connection limit means more popular/common user"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more predictable order might be easier to compare from time to time.
But I'm not adamant about it.
@@ -30,7 +29,7 @@ func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...fu | |||
return err | |||
} | |||
defer conn.Close(context.Background()) | |||
rows, err := conn.Query(ctx, TotalTableSizesQuery, reset.LikeEscapeSchema(utils.PgSchemas)) | |||
rows, err := conn.Query(ctx, TotalTableSizesQuery, reset.LikeEscapeSchema(utils.InternalSchemas)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure that users are not interested in the size of managed schemas, like auth.users
table for eg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe for auth, yep. For others, less so because they are managed and should not be touched (so they may cause issues but nothing the user can resolve)
…s thrown when report directory cannot be made
b9644ed
to
9f4a035
Compare
What kind of change does this PR introduce?
Feature
What is the current behavior?
Currently, inspect reports are quite modular and provide output where column titles can vary
What is the new behavior?
Refined queries to output in a similar format and reduced/combined work to minimise the number of output files produced (or commands needed)
Additional context
CSVQ has been added as a library to provide a table printout of some rules that are/are not met by the CSV files produced by
report