Understanding PostgreSQL Reset Statistics with pg_stat_reset

PostgreSQL Reset Statistics with pg_stat_reset

This article will explore focus on how to PostgreSQL reset statistics using the pg_stat_reset command. We will discuss what this command does, when and why to use it, and the impact it has on your PostgreSQL database. Efficiency is important, so check out this article on how to reload config using pg_ctl without restarting the … Read more

PostgreSQL By Example: Reload pg_hba.conf

postgresql show tables

This file controls client authentication, and its modifications won’t take effect until you reload pg_hba.conf. In this comprehensive guide, we’ll answer the top ten questions about reloading the pg_hba.conf file. What is the command to reload the pg_hba.conf file in PostgreSQL? The command to reload pg_hba.conf file in PostgreSQL is fairly simple. Use the following … Read more

How to backup/dump a PostgreSQL database using pg_dump

postgresql show tables

This article will show you how to use the pg_dump utility that is built-in to PostgreSQL to backup or dump the database to a file. This is a utility I use all the time to quickly make periodic backups of my databases. This tool has the ability to create both compressed and uncompressed dumps of … Read more

How to find (log) slow queries in PostgreSQL 8.x, 9.x

One of the most important factors when troubleshooting the performance of an application or website, is the performance of the database. Improper indexing or inefficient SQL queries can kill the performance of your application rendering it useless. It is amazing what a simple tweak or change to a SQL statement can do. I have seen … Read more

How to install PostgreSQL 8.4 on CentOS 5.5

postgresql show tables

If you have tried installing PostgreSQL database on CentOS 5.5 using yum, you will notice that you have an old, outdated version! There are several ways to get the 8.4.x version of Postgres installed on this OS, but here is the quick and easy method! Installing PostgreSQL 8.4.x on CentOS 5.5

PostgreSQL: How to reload config settings without restarting database

postgresql show tables

Reloading the PostgreSQL configuration without restarting the entire database can be efficiently achieved using the pg_ctl reload command. Performing Postgres reload config is a simple one-liner and should be part of your toolbox. Why is Postgres Reload Config Important? If you are making modifications to the Postgres configuration file postgresql.conf (or similar), and you want … Read more

How to view table/row locks in PostgreSQL?

postgresql show tables

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 … Read more

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 … Read more

How to find when PostgreSQL Vacuum and Analyze were run?

postgresql vaccuum, postgres autovacuum, postgres vacuum

This article will show you how to determine when your database tables were last vacuumed, auto-vacuumed, analyzed, and auto-analyzed on a PostgresSQL database. Performing these operations are critical in keeping the database optimized and performant. What is the purpose of PostgreSQL Vacuum? PostgreSQL’s “VACUUM” is a maintenance operation designed to reclaim storage occupied by expired … Read more

How to Delete/Drop a Constraint In PostgresSQL

postgresql show tables

This article will show you how to drop a constraint, such as a foreign key constraint, on a PostgresSQL database. There are several different types of constraints and we’ll show you examples of each. Sure, here are the same instructions with headers and sub-headers: Dropping a PRIMARY KEY Constraint in PostgreSQL To remove a primary … Read more

Find PostgreSQL database size using SQL ‘Select’

postgresql show tables

This article will show you a very simple way to find the size of a PostgreSQL database using a SQL SELECT statement. This will work on PostgreSQL version 8.3.3, but should work on older versions as well. Looking for optimize your database performance, check out How to find when PostgreSQL tables were auto-vacuumed and auto-analyzed … Read more