Re: BASH script for collecting analyze-related info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.tanzer@xxxxxxxxxxxxxxxxxxx
(253) 245-3801

Subscribe to the mailing list to
learn more about AGENCY or
follow the discussion.

Attachment: pg_analyze_info.sh
Description: Bourne shell script

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux