Re: BASH script for collecting analyze-related info

Поиск
Список
Период
Сортировка
От Ken Tanzer
Тема Re: BASH script for collecting analyze-related info
Дата
Msg-id CAD3a31WkQ3YkksK8Aghh4u+fPA2YTsFrW3xEekCnK3STeZ4uYg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BASH script for collecting analyze-related info  (hubert depesz lubaczewski <depesz@depesz.com>)
Список 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
(253) 245-3801

learn more about AGENCY or
follow the discussion.
Вложения

В списке pgsql-performance по дате отправления:

Предыдущее
От: Xenofon Papadopoulos
Дата:
Сообщение: Re: pg_statio_all_tables columns
Следующее
От: Xenofon Papadopoulos
Дата:
Сообщение: Reseting statistics counters