Infrastructure at your Service

PostgreSQL Archives - Page 18 of 21 - Blog dbi services

Daniel Westermann

Monitoring tools for PostgreSQL – POWA

By | Database Administration & Monitoring, Database management | No Comments

The last posts introduced the logging system, pg_stat_statements, pg_activity and pgcluu. This post will look at POWA: PostgreSQL Workload Analyzer. For getting the most out of POWA the following extension should be installed in the PostgreSQL instance you want to monitor: pg_stat_statements (see last post) pg_stat_kcache: gathers statistics about reads and writes done by the file system layer pg_qualstats: gathers statistics of predicates found in where statements and join clauses btree_gist: provides GiST index operator…

 
Read More
Daniel Westermann

Monitoring tools for PostgreSQL – pgcluu

By | Database Administration & Monitoring | No Comments

The last posts introduced the logging system, pg_stat_statements and pg_activity. All of these can be used to monitor sql statements the PostgreSQL server is executing. In this post I’ll look into pgcluu: PostgreSQL Cluster utilization! This is a more complete monitoring solution as it is not only focused on sql statements but gives you information about the database cluster itself and other useful stuff. All you need to run pgcluu is a modern perl distribution…

 
Read More
Daniel Westermann

SQL Monitoring in PostgreSQL (3) – pg_activity

By | Database Administration & Monitoring | 7 Comments

The last posts looked at how the logging system and the pg_stat_statements extension can be used to monitor sql statements in PostgreSQL. This post will introduce pg_activity which is very similar to htop. There are some dependencies which need to be installed before we can start installing pg_activity. The first one is python. As I am on a redhat based distribution this is quite easy: [root@oel7 ~] yum install -y python Then we need to…

 
Read More
Daniel Westermann

SQL Monitoring in PostgreSQL (2) – pg_stat_statements

By | Database Administration & Monitoring | No Comments

The last post looked into how you can monitor queries using the logging system. This post will introduce pg_stat_statements. pg_stat_statements is a module that needs to be loaded and is not available in the default configuration. Loading it is quite easy. Create the extension as usual: postgres@oel7:/home/postgres/ [PG6] sqh Null display is “NULL”. Timing is on. psql (9.5alpha2) Type “help” for help. (postgres@[local]:4448) [postgres] > create extension pg_stat_statements; CREATE EXTENSION Time: 281.765 ms (postgres@[local]:4448) [postgres]…

 
Read More
Daniel Westermann

SQL Monitoring in PostgreSQL (1) – the logging system

By | Database Administration & Monitoring | No Comments

When developing an application as well as when the application is in production there is the need to identify long running queries. In Oracle one tool you might use for that is the SQL Monitor. In this post I’ll look into what PostgreSQL provides in this area. PostgreSQL has a very strong logging system. This system can be used to log many, many server messages as well as information about sql queries. To enable to…

 
Read More
Daniel Westermann

Upgrading PostgreSQL to a new major release

By | Database Administration & Monitoring | No Comments

The last post looked into how to upgrade PostgreSQL to a new minor version. In this post I’ll look into how to upgrade PostgreSQL to a new major version. This is not as simple as just installing the binaries and start the instance from there. For major upgrades there are two possibilities: dump the old version and restore into the new version by using pg_dump and pg_restore use pg_upgrade I’ll only look into pg_upgrade for…

 
Read More
Daniel Westermann

Patching PostgreSQL to a new minor release

By | Database Administration & Monitoring | 3 Comments

If you are used to patch Oracle databases you probably know how to use opatch to apply PSUs. How does PostgreSQL handle this? Do we need to patch the existing binaries to apply security fixes? The answer is: No. Lets say you want to patch PostgreSQL from version 9.4.1 to version 9.4.5. What do you need to do? For this little demo I’ll create a new database and a sample table in my 9.4.1 instance:…

 
Read More
Daniel Westermann

Migrating the Oracle 12cR1 sample schemas to PostgreSQL Plus Advanced Server 9.4

By | Database Administration & Monitoring | No Comments

This post takes a look on how to migrate the Oracle 12cR1 sample schemas to PPAS 9.4 (PostgreSQL Plus Advanced Server 9.4). I’ll not dig into how to install PPAS as this was described in detail some time ago. Just follow this post if you need a setup guide. If you wonder why I am doing this there are two reasons: to see if it works, to have fun and to learn PostgreSQL and PPAS…

 
Read More
Daniel Westermann

Row level security is coming to PostgreSQL

By | Database Administration & Monitoring | No Comments

Before PostgreSQL 9.5 (which is in alpha2 currently) you could grant access to individual columns of a table to users or roles. A little test script to demonstrate this: (postgres@[local]:5432) [postgres] > select version(); version ————————————————————————————————————– PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit (1 row) create table t ( id int primary key, name varchar(50), salary bigint ); insert into t ( id, name, salary ) values (…

 
Read More
Daniel Westermann

Representing ranges with one data type?

By | Database Administration & Monitoring | No Comments

How many applications do you know that need to define a validity of a row? And how many of these do that by adding two columns: valid_from and valid_to or similar column names? Well, in PostgreSQL (you already suspect it ) there is much more elegant way to do that. PostgreSQL knows the concept of range types. Several of these are pre-defined and you get them once you install PostgreSQL: int4range — Range of integer…

 
Read More