Archive for August, 2010

How to view table/row locks in Postgres?

This article will show you how to see a list view a list of locks that are currently open (or waiting) on your database rows and tables. This information is beneficial when debugging timing-related errors and data inconsistencies. Login to the PostgresSQL command-line interface psql -U [username] [database_name] Run the following query: select t.relname,l.locktype,page,virtualtransaction,pid,mode,granted from [...]

Click here to read the full post

How to see active SQL queries and open connections in Postgres?

This article will show you how to see a list of open database connections as well as all active queries that are running on a PostgresSQL 8.x database. This information can be very beneficial when profiling your application and determining queries that have “gone wild” and are eating CPU cycles. Login to the PostgresSQL command-line [...]

Click here to read the full post

How to find when Postgres tables were auto-vacuumed and auto-analyzed?

This article will show you how to determine when your database tables were last vacuumed, auto-vacuumed, analyzed, and auto-analyzed on a PostgresSQL 8.x database. Login to the PostgresSQL command-line interface psql -U [username] [database_name] Run the following query: select relname,last_vacuum, last_autovacuum, last_analyze, last_autoanalyze from pg_stat_user_tables;

Click here to read the full post