Londiste Replication with PostgreSQL 9.0

Londiste, Asynchronous Master/Slave replication tool developed by Skytools. Its very simple and user-friendly created like Slony. Core logic behind Londiste or Slony is Remote Triggering. Whereas londiste follows events queuing model which is not their in Slony - I. Overview on Skytools: Skytools is a Python-based application, it comes with a bundle of three things PgQ,Londiste & Walmgr and it also requires the Python-Postgres driver ‘psycopg2’. PGQ : Its queue mechanism built with pl/pgsql with phython framework on top of it.

Continue reading →

Resize VARCHAR column of a Large Tables

Note: Recommended not to tamper pg_catalogs. On forum, I saw an interesting posting and also the solution, however few things of that solution made me to test it. Scenario is, “How to resize the VARCHAR column on a large table with less time and what are best approach’s”. As known standard way is to, Create a NEW column with desired size, Copy OLD data to newly created column, Drop the OLD column and finally rename the NEW with OLD column name.

Continue reading →

Deadlocks in PostgreSQL

Before discussing on deadlocks, lets see type of locks and their acquiring methodolgy in PostgreSQL. Types of Locks: Table-Level Locks and Row-Level Locks Table-Level Locks: AcessShareLock : It acquired automatically by a SELECT statement on the table or tables it retrieves from. This mode blocks ALTER TABLE, DROP TABLE, and *VACUUM (AccessExclusiveLock) *on the same table RowShareLock :It acquired automatically by a SELECT…FOR UPDATE clause. It blocks concurrent ExclusiveLock and *AccessExclusiveLock *on the same table.

Continue reading →

~/.psqlrc file for DBA's

In our regular DBA monitoring, we will be using so many combination of pg_catalog queries to reteive information like <IDLE> in transaction , waiting queries, No. of connections, etc. Most of the DBA’s, create views to cut short big combination queries and keep handy for later use per requirement. PostgreSQL, provides a startup file(.psqlrc) which executes before connecting to the database when using with psql utility. Using .psqlrc file you can place all your important queries with one word alias by ‘\set’ command and execute it in psql terminal instead of typing big queries.

Continue reading →

High Availability Clustering with PostgreSQL

Firstly, I should thank my company for giving me an opportunity to work mostly with PostgreSQL HA stuff. I have worked with very good clients who has implemented Clustering with PostgreSQL. So, my article here is to give little idea on how HA clustering will work with PostgreSQL. PostgreSQL has built-in functionality for High Availability like Warm Standby,Hot Standby and Streaming Replication. But, missing few features like Switchover/Switchback, failover automation, minimal downtime etc.

Continue reading →