Skip to content
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

Command line improvements #7

Closed
MichaelDBA opened this issue Mar 8, 2018 · 6 comments
Closed

Command line improvements #7

MichaelDBA opened this issue Mar 8, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@MichaelDBA
Copy link

First of all, thanks for your new tool! Here are a few suggestions:

  1. Make table output optional or filterable through a new command parameter. Thousands of tables within a database can cause a lot of unwanted output, perhaps something like --no-tables.

  2. Add a schema option to limit table output, --schema schema1, schema2

  3. Put system information output before table output. That way top level stuff is always at top.

Keep up the good work!

@mdevan
Copy link
Contributor

mdevan commented Mar 8, 2018

Thanks, good suggestions!

How about a couple of options like:

--match-table=PATTERN    include only tables whose name matches PATTERN
--match-schema=PATTERN   include objects only from schema that match PATTERN

where PATTERN is a POSIX regular expression, and if it starts with ! then the meaning is inverted (exclude tables/schema). Both options may be used at the same time and works like "AND".

Do you think this will fit your use cases?

@mdevan mdevan added the enhancement New feature or request label Mar 8, 2018
@MichaelDBA
Copy link
Author

MichaelDBA commented Mar 8, 2018

The regex stuff is more than I asked for, but sure that'll work for most table and schema filtering, but what about the case where I don't want table info? Now I have to write a regex pattern that will not return anything as opposed to a parameter that just says --no-tables and/or --no-schemas. How about both? Also, if I use regex filtering it makes it more difficult than to specify 2 schemas directly with the --schema parameter which expects a comma-delimited list of schemas.

It seems to me regex stuff is more applicable to tables where you could have thousands, but not to schemas where you might have a few. So I would recommend the regex for tables but a comma-delimited list for schemas.

Also, don't forget about the system info being placed before table output.

2 ways to specify schemas:

--schemas schema1, schema2
--schema schema1 --schema schema2

@mdevan
Copy link
Contributor

mdevan commented Mar 9, 2018

OK, let's list down the items.

  1. filter tables: use an option to include/exclude tables based on regexps
  2. filter schema: use a repeatable option to only include objects from the specified schema

These two sound good, let's go with it.

I guess the third item is what objects we should collect from a single database. Right now, pgmetrics gets information about:

  • tables
  • indexes
  • sequences
  • user function timings
  • extensions (this one is not schema-specific)
  • disabled triggers

So if we want to collect only some of these types, then there should be an option that specifies that, I think. Like "--collect=tables,indexes" would collect only tables and indexes, or "--collect=all" would collect everything. Thoughts?

And the fourth one is about the report cosmetics, which we'll handle separately in another issue -- it is not related to data collection after all. (And I agree, it makes sense to put it just below the "PostgreSQL Cluster:" section. It gives more context for the rest of the report.)

@mdevan
Copy link
Contributor

mdevan commented Apr 4, 2018

b38c9ec includes these schema and table selection options:

Collection options:
  -c, --schema=REGEXP          collect only from schema(s) matching POSIX regexp
  -C, --exclude-schema=REGEXP  do NOT collect from schema(s) matching POSIX regexp
  -a, --table=REGEXP           collect only from table(s) matching POSIX regexp
  -A, --exclude-table=REGEXP   do NOT collect from table(s) matching POSIX regexp

These are similar to pg_dump's options, except that it's based on regexp.

@mdevan
Copy link
Contributor

mdevan commented Apr 5, 2018

13393c2 shows the system information earlier on in the output.

@mdevan
Copy link
Contributor

mdevan commented Apr 5, 2018

51462e3 includes option to omit the collection of one or more of: tables, indexes, sequences, functions, extensions and triggers.

      --omit=WHAT              do NOT collect the items specified as a comma-separated
                                   list of: "tables", "indexes", "sequences",
                                   "functions", "extensions", "triggers"

That addresses all the points in this issue, I think. Feel free to reopen this/open another issue if it doesn't.

@mdevan mdevan closed this as completed Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants