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 active queries

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 active queries

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 on CentOS using Yum

postgresql active queries

PostgreSQL is a powerful, open-source relational database system that’s widely used for its reliability and flexibility. If you’re setting up PostgreSQL on CentOS, you’re in the right place. This guide will walk you through the installation process, from adding the necessary repository to configuring the database for remote access. Step 1: Set Up the PostgreSQL … Read more

PostgreSQL: How to reload config settings without restarting database

postgresql active queries

Reloading PostgreSQL settings without restarting keeps your database running smoothly. It ensures updates to files like postgresql.conf and pg_hba.conf apply right away without stopping queries or breaking connections. This guide explains three methods to reload settings, shares useful tips, and offers troubleshooting advice. Why Reload PostgreSQL Configurations? When you update files such as: changes don’t … Read more

How to view table/row locks in PostgreSQL?

postgresql active queries

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?

postgresql active queries

If you’re working with a PostgreSQL database, keeping tabs on active queries is a must to keep things running smoothly. Let it slide, and you could end up with sluggish performance—or even a database that stops working altogether. The upside? PostgreSQL has built-in features to help you stay on top of what’s happening. This guide … 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 active queries

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 active queries

PostgreSQL is one of the most powerful and widely used relational database management systems (RDBMS). Managing database size effectively is crucial to ensure performance, scalability, and efficient resource utilization. Understanding how to measure and monitor database size is an essential skill for database administrators and developers. This article explores how to find the PostgreSQL database … Read more