Webinar: pg_catalog Unveiled! [Follow Up]

April 13, 2020

PostgreSQL users are always interested in their system’s performance to know if any improvements need to be made or to generate the occasional health report requested by their managers. 

Standard monitoring tools are available to monitor the CPU, RAM, and I/O consumption, but they won’t be able to tell you if indexes are being used, if tables are bloated, if there is a lag of replication or a variety of other interesting and useful things within the PostgreSQL environment. 

To explore these features and more, 2ndQuadrant held a live webinar titled “pg_catalog Unveiled!”, hosted by Boriss Mejías (PostgreSQL Consultant at 2ndQuadrant).

This webinar reviewed the possibilities offered by the PostgreSQL catalog. We also explored how to exploit the catalog, how to send the information to other monitoring tools, and how the tables in pg_catalog are fundamentally interconnected to other matters such as performance, replication, MVCC, security, etc.

Those who weren’t able to attend the live webinar can now view the recording here.

Due to limited time, some of the questions were not answered during the live webinar; so answers by the host are provided below:


Question: Do we need to run vacuum and analyze for catalog tables as well?

Answer: Note that catalog tables also need to be vacuumed and analyzed. This is done automatically by autovacuum, but you could also monitor the bloat of the catalog tables by looking at `pg_stat_sys_tables`. Also, note that many of the tables we use during the talk are `views`, not physical tables.

 

Question: After seeing the temp files, how do you release those temp files?

Answer: During the presentation, we discussed investigating temporary files to know if we need a higher value for `work_mem`. Those temporary files are managed by PostgreSQL, you don’t have to remove them yourself. PostgreSQL will remove them immediately once the query has finished.

 

Question: We have a lot of open source utilities to monitor Postgres — can you name some of the very useful ones?

Answer: Icinga and Nagios are very popular. Although OmniDB is not a monitoring tool, it has a monitoring dashboard.

 

Question: Where can we track deadlocks in PostgreSQL?

Answer: We can only observe the number of deadlock in the catalog as we saw during the presentation. To track the details of each deadlock occurrence, you have to check PostgreSQL logs. They are always logged.

 

Question: If query performance goes bad after ANALYZE is there a way to rollback stats from stats catalog tables?

Answer: No, there is no way of rolling back statistics. But if you are getting bad performances after running ANALYZE, you may have special data distribution and you should have a look at CREATE STATISTICS

 

Question: I have the following results of temporary files: temp_files 380, pg_size_pretty 227 GB, I must do something?

Answer: Yes, activate log temporary files and try to find a size that covers 80%-90% of your temporary files, and increase `work_mem` to that value. Make sure you have enough RAM for that.

 

Question: Hi, How can we get some kind of slow queries history?

Answer: Not in the catalog, but see pg_stat_statements

 

Question: What’s the difference in design rationale between information_schema and pg_catalog?

Answer: Information_schema follows the design of the SQL standard. pg_catalog is designed by the PostgreSQL developers team to suit the specific needs of PostgreSQL. Many of the data in information_schema are views to pg_catalog.

 

Question: We sometimes see the autovacuum worker process is running in the middle of the day, can we move them in the maintenance window? what are the pros and cons?

Answer: Scheduling the VACUUM job at night will let you start the days with clean tables, delaying the first run of autovacuum. Don’t disable autovacuum because if you don’t run autovacuum when needed, the planner will make decisions based on outdated stats, and the tables will contain more bloat than recommended, which is also bad for performance.


To stay updated on upcoming webinars by 2ndQuadrant, you can visit our Webinars page.

For any questions, comments, or feedback, please visit our website or send an email to webinar@2ndquadrant.com.

Share this

More Blogs