Re: BASH script for collecting analyze-related info

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: depesz(at)depesz(dot)com
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: BASH script for collecting analyze-related info
Date: 2013-10-01 02:40:55
Message-ID: CAD3a31WkQ3YkksK8Aghh4u+fPA2YTsFrW3xEekCnK3STeZ4uYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Thanks for the suggestions, help and feedback. New version attached.

3. When extracting table names you are missing:
> a. Index Scan Backward
> b. Bitmap Heap Scan
> 4. When extracting index names, you're missing Index Only Scans and Index
> Scan Backwards.

If someone can send me analyze output with these characteristics, I'll try
to get the script to pick them up.

5. The whole script will fail if you're using table names with spaces (not
> that
> I think this is sane, but the script should recognize it)

Uggh yes. I imagine it will fail on international characters as well. Not
sure if I want to tackle that right now, though suggestions welcome. (Or
if someone else wants to do it!) I did tweak so that quoted identifiers
will work, e.g. mixed case field names, and also ones with the $ sign. I
completely understand people using other languages, but really do people
need spaces in their names? :)

2. why is there union with nulls in the last query?

Laziness, convenience or expediency, pick your preferred label. I needed
something to go with the last "UNION" that was generated. I changed it to
do this more cleanly.

1. instead of: "SELECT 'Postgres Version';" it's better to use \echo
> Postgres Version

Much better. I used qecho so it can be redirected with the rest of the
output.

That is - I removed the "\" at the end - it's of no use.
>

Great. I ended up taking them all out.

> 6. It's generally better to use
> if [[ ...
> than
> if [ ...
> reason - [[ is internal for bash, while [ is fork to external program
> 7. instead of | sort | uniq, it's better to use sort -u
>

Check and check, did both of these

> 8. usage of all-upper-case variables in bash is (by some, more
> bash-skilled people, like on #bash on irc.freenode) frowned upon.
> all-uppercase is supposed to be for environment variables only.
>

Personally I like the upper case names as they stand out easily in the
script. But I'd hate to be frowned on by the bashers (or bashed by the
frowners), so I changed them to lower case.

> All in all - looks pretty good.
>
>
Thanks!

Cheers,
Ken

--
AGENCY Software
A data system that puts you in control
100% Free Software
*http://agency-software.org/*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing
list<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe>
to
learn more about AGENCY or
follow the discussion.

Attachment Content-Type Size
pg_analyze_info.sh application/x-sh 3.2 KB

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Xenofon Papadopoulos 2013-10-01 11:50:29 Reseting statistics counters
Previous Message Xenofon Papadopoulos 2013-09-30 17:50:17 Re: pg_statio_all_tables columns