Quantcast
Channel: Planet PostgreSQL
Viewing all 9665 articles
Browse latest View live

Jeff McCormick: What's New in Crunchy PostgreSQL Operator 3.5

$
0
0

Crunchy Data is happy to announce the release of the open source  PostgreSQL Operator 3.5 for Kubernetes project, which you can find here: https://github.com/CrunchyData/postgres-operator/

This latest release provides further feature enhancements designed to support users intending to deploy large-scale PostgreSQL clusters on Kubernetes, with enterprise high-availability and disaster recovery requirements.

When combined with the Crunchy PostgreSQL Container Suite, the PostgreSQL Operator provides an open source, Kubernetes-native PostgreSQL-as-a-Service capability.

Read on to see what is new in PostgreSQL Operator 3.5.


Umur Cubukcu: Microsoft Acquires Citus Data: Creating the World’s Best Postgres Experience Together

$
0
0

Citus Data & Microsoft

Today, I’m very excited to announce the next chapter in our company’s journey: Microsoft has acquired Citus Data.

When we founded Citus Data eight years ago, the world was different. Clouds and big data were newfangled. The common perception was that relational databases were, by design, scale up only—limiting their ability to handle cloud scale applications and big data workloads. This brought the rise of Hadoop and all the other NoSQL databases people were creating at the time. At Citus Data, we had a different idea: that we would embrace the relational database, while also extending it to make it horizontally scalable, resilient, and worry-free. That instead of re-implementing the database from scratch, we would build upon PostgreSQL and its open and extensible ecosystem.

Fast forward to 2019 and today’s news: we are thrilled to join a team who deeply understands databases and is keenly focused on meeting customers where they are. Both Citus and Microsoft share a mission of openness, empowering developers, and choice. And we both love PostgreSQL. We are excited about joining forces, and the value that doing so will create: Delivering to our community and our customers the world’s best PostgreSQL experience.

As I reflect on our Citus Data journey, I am very proud of what our team has accomplished. We created Citus to transform PostgreSQL into a distributed database—giving developers game-changing performance improvements and delivering queries that are magnitudes faster than proprietary implementations of Postgres. We packaged Citus as an open source extension of PostgreSQL—so you could always stay current with the latest version of Postgres, unlike all forks of databases prior to it. We launched our Citus Cloud database as a service and grew it to power billions of transactions every day—creating the world’s first horizontally scalable relational database that you can run both on premises, and as a fully-managed service on the cloud.

The most fulfilling part of this journey has been seeing all the things our customers can now do because of Citus—from SaaS companies who run their core applications on Citus Cloud to scale their business on-demand; to large enterprises who use Citus to power their real-time analytics dashboards; to organizations who serve both transactional and analytical workloads with one database (Citus); to Fortune 100 companies who are now able to migrate to an open, horizontally scalable Postgres ecosystem; to developers who now have a more scalable and performant way to power their workloads—all without re-architecting their applications.

As part of Microsoft, we will stay focused on building an amazing database on top of PostgreSQL that gives our users the game-changing scale, performance, and resilience they need. We will continue to drive innovation in this space. We remain as committed to our customers as ever, and will continue providing the strong support for the products our customers use today. And we will continue to actively participate in the Postgres community, working on the Citus open source extension as well as the other open source Postgres extensions you love.

All of this would not have been possible without the support of the PostgreSQL community, our customers, and the amazing team we are privileged to work with. We are humbled to work with all of you, and we are looking forward to working together as we deliver ever bigger things to our community, our users, and our customers in the next chapter of our journey—now as part of Microsoft.

To read more about our exciting news, please visit the Official Microsoft Blog.

Umur Cubukcu, Ozgun Erdogan, and Sumedh Pathak, co-founders of Citus Data

Citus Data team
Citus Data team

Robert Haas: How Much maintenance_work_mem Do I Need?

$
0
0
While I generally like PostgreSQL's documentation quite a bit, there are some areas where it is not nearly specific enough for users to understand what they need to do. The documentation for maintenance_work_mem is one of those places. It says, and I quote, "Larger settings might improve performance for vacuuming and for restoring database dumps," but that isn't really very much help, because if it might improve performance, it also might not improve performance, and you might like to know which is the case before deciding to raise the value, so that you don't waste memory.  TL;DR: Try maintenance_work_mem = 1GB.  Read on for more specific advice.

Read more »

Vasilis Ventirozos: PostgreSQL 12 : Where in copy from

$
0
0
5 days ago a commit made it to 12devel that implements WHERE clause in COPY FROM.
Today we're gonna see how it works and see how someone could achieve the same by using file_fdw.

To begin with, lets create a table and put some data in it.

create table test (
id int,
date timestamp without time zone,
);

insert into test (id,date) select generate_series (1,1000000)            ,'2015-01-01';
insert into test (id,date) select generate_series (1000001,2000000),'2016-01-01';
insert into test (id,date) select generate_series (2000001,3000000),'2017-01-01';
insert into test (id,date) select generate_series (3000001,4000000),'2018-01-01';
insert into test (id,date) select generate_series (4000001,5000000),'2019-01-01';

now, lets make this a bit larger than 170MB, dump the data in csv and truncate the table :

monkey=# insert into test select * from test;
INSERT 0 5000000
monkey=# insert into test select * from test;
INSERT 0 10000000
monkey=# select count(*) from test ;
  count
----------
 20000000
(1 row)

monkey=# copy test to '/home/vasilis/test.csv' with csv;
COPY 20000000

monkey=# truncate test;
TRUNCATE TABLE

vasilis@Wrath > ls -lh ~/test.csv
-rw-r--r-- 1 vasilis vasilis 759M Jan 25 12:24 /home/vasilis/test.csv

Our test file is about 750Mb, now with an empty table , lets import only the rows that are up to 2 years old :

monkey=# copy test from '/home/vasilis/test.csv' with csv where date >= now() - INTERVAL '2 year' ;
COPY 8000000
Time: 17770.267 ms (00:17.770)

It worked , awesome !

Now, lets compare to the alternative, file_fdw :

monkey=# CREATE EXTENSION file_fdw;
CREATE EXTENSION
Time: 7.288 ms

monkey=# CREATE SERVER pgtest FOREIGN DATA WRAPPER file_fdw;
CREATE SERVER
Time: 3.957 ms

monkey=# create foreign table file_test (id int, date timestamp without time zone, name text) server pgtest options (filename '/home/vasilis/test.csv', format 'csv');
CREATE FOREIGN TABLE
Time: 16.463 ms

monkey=# truncate test ;
TRUNCATE TABLE
Time: 15.123 ms

monkey=# insert into test select * from file_test where date >= now() - INTERVAL '2 year' ;
INSERT 0 8000000
Time: 21368.595 ms (00:21.369)


I automated the test, and copy was (obviously) always faster. I'd imagine that the key benefit here is not performance, which is inherited by COPY itself but extending the functionality of COPY, which is good, especially for workloads that export data , ETL and load to another DB, or for restoring specific rows from backups (assuming pg_dump backups is still a thing).




Thanks for reading
Vasilis Ventirozos
Credativ

Jehan-Guillaume (ioguix) de Rorthais: Build a PostreSQL Automated Failover in 5 minutes

$
0
0

I’ve been working with Vagrant to quickly build a fresh test cluster for PAF development. Combined with virsh snapshot related commands, I save a lot of time during my tons of tests by quickly rollbacking the whole cluster to the initial state.

Continue Reading »

Bruce Momjian: Pooler Authentication

$
0
0

One frequent complaint about connection poolers is the limited number of authentication methods they support. While some of this is caused by the large amount of work required to support all 14 Postgres authentication methods, the bigger reason is that only a few authentication methods allow for the clean passing of authentication credentials through an intermediate server.

Specifically, all the password-based authentication methods (scram-sha-256,md5,password) can easily pass credentials from the client through the pooler to the database server. (This is not possible using SCRAM with channel binding.) Many of the other authentication methods, e.g. cert, are designed to prevent man-in-the-middle attacks and therefore actively thwart passing through of credentials. For these, effectively, you have to set up two sets of credentials for each user — one for client to pooler, and another from pooler to database server, and keep them synchronized.

A pooler built-in to Postgres would have fewer authentication pass-through problems, though internal poolers have some down sides too, as I already stated.

Sebastian Insausti: Top GUI Tools for PostgreSQL

$
0
0

Managing databases from the command line does come with a learning curve to get the most out of it.

The command line can sometimes be arduous and the display may not be optimal for what you are doing.

Browsing through databases and tables, checking indexes or user privileges, monitoring, managing, and even coding can get really messy when trying to handle it through the console.

It’s not that you don't need to manage the command line commands (it's for sure a must), but there are some tools that can help you speed up many of the daily DBA tasks.

Let's look at what these tools are about and review some of them.

What is a GUI Tool?

A GUI or Graphical User Interface is a software that simplifies the tasks of the users through graphical icons and visual indicators. The actions are performed by using graphical elements.

Why Should I Use a GUI Tool?

Using a GUI is not a must, but it can be useful. One of the main advantages of the GUIs is that they are, in general, easier to learn than a lot of commands and probably one action on the GUI could generate a few commands to perform the task.

Another advantage could be that the GUI is more friendly than the command line, and in most cases, you don't need any programming or sysadmin knowledge to use it.

But, you should be careful before performing a task from the GUI, because by using the wrong button, you could generate a big issue like deleting a table; and for this reason, do be careful when using this kind of tool.

Top GUI Tools for PostgreSQL

Now, let's see some of the most commons GUI tools for PostgreSQL.

Note that, for the installation examples, we'll test it on Ubuntu 18.04 Bionic.

pgAdmin

pgAdmin is one of the most popular Open Source administration and development platforms for PostgreSQL.

It's designed to meet the needs of both novice and experienced PostgreSQL users alike, providing a powerful graphical interface that simplifies the creation, maintenance and use of database objects.

It's supported on Linux, Mac OS X, and Windows. It supports all PostgreSQL features, from writing simple SQL queries to developing complex databases. It's designed to query an active database, allowing you to stay current with modifications and implementations. pgAdmin 4, the current version, can manage PostgreSQL 9.2 and above.

Features

  • Graphical query plan display
  • Grant wizard for rapid updates to ACLs
  • Procedural language debugger
  • Auto-vacuum management
  • Monitoring dashboard
  • Backup, restore, vacuum and analyze on demand
  • SQL/shell/batch job scheduling agent
  • Auto-detection and support for objects discovered at run-time
  • A live SQL query tool with direct data editing
  • Support for administrative queries
  • A syntax-highlighting SQL editor
  • Redesigned graphical interfaces
  • Powerful management dialogs and tools for common tasks
  • Responsive, context-sensitive behavior
  • Supportive error messages
  • Helpful hints
  • Online help and information about using pgAdmin dialogs and tools

Installation

First, we need to import the repository key.

$ sudo apt-get install curl ca-certificates
$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

And create the /etc/apt/sources.list.d/pgdg.list file. The distributions are called codename-pgdg. In our example should be bionic-pgdg.

$ deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

To determine the codename of your distribution you can run the lsb_release -c command.

After this, you need to update the package lists, and install the pgadmin package:

$ sudo apt-get update
$ sudo apt-get install pgadmin4

Then, you only need to run the pgadmin4 command:

$ pgadmin4

Configuration

The installation creates a pgAdmin server listening in a specific port. This port changes every time you run the pgadmin4 command. After the program is running, you can manage your database from a web interface accessing by the pgAdmin icon on the taskbar.

To connect to your database, you need to choose the Add New Server option and complete the connection information.

Then, you can manage your database using pgAdmin 4.

The design looks good and it's an intuitive interface. The charts in the main screen could help to detect some issue on your system.

The installation requires adding a repository, so it could require some additional skills.

Adminer

Adminer is a full-featured database management tool written in PHP.

It consists of a single file ready to deploy to the target server.

Adminer is available for MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Firebird, SimpleDB, Elasticsearch, and MongoDB. The current version is 4.7 and it was released in November.

Features

  • Connect to a database server with username and password
  • Select an existing database or create a new one
  • List fields, indexes, foreign keys and triggers of a table
  • Change name, engine, collation, auto_increment, and comment of table
  • Alter name, type, collation, comment and default values of columns
  • Add and drop tables and columns
  • Create, alter, drop and search by indexes including full-text
  • Create, alter, drop and link lists by foreign keys
  • Create, alter, drop and select from views
  • Create, alter, drop and call stored procedures and functions
  • Create, alter and drop triggers
  • List data in tables with search, aggregate, sort and limit results
  • Insert new records, update and delete the existing ones
  • Supports all data types, blobs through file transfer
  • Execute any SQL command from a text field or a file
  • Export table structure, data, views, routines, databases to SQL or CSV
  • Print database schema connected by foreign keys
  • Show processes and kill them
  • Display users and rights and change them
  • Display variables with links to documentation
  • Manage events and table partitions
  • PostgreSQL
    • Schemas, sequences, user types
  • Extensive customization options

Installation

It runs in a web server, so first, you need to install Apache2, php, php-pdo and php-pgsql packages.

$ sudo apt install apache2 php php-pdo php-pgsql

We need to download the PHP file from the Adminer web page:

$ wget https://github.com/vrana/adminer/releases/download/v4.7.1/adminer-4.7.1.php

And we need to move the PHP file to our apache document root:

$ sudo mv adminer-4.7.1.php /var/www/html/adminer.php

Then, if you're installing it on your local machine, you need to open the URL http://localhost/adminer.php in your web browser.

Configuration

To start using the tool, you need to login into your database.

After login, you can see the following web page.

The installation is really easy because you only need to put the PHP file in the document root of your web server, but the interface looks a bit old-fashioned.

It's a web application, so you can access it from everywhere only by using a web browser.

SQL Workbench/J

SQL Workbench/J is a free, DBMS-independent, cross-platform SQL query tool.

It is written in Java and should run on any operating system that provides a Java Runtime Environment.

Its main focus is on running SQL scripts and export/import features. Graphical query building or more advanced DBA tasks are not the focus and are not planned.

Features

  • Edit, insert and delete data directly in the query result
  • Powerful export command to write text files, XML, HTML or SQL.
  • All user tables can be exported into a directory with a single command. Export files can be compressed "on-the-fly".
  • Powerful text, XML and spreadsheet import. A set of files can be imported from a directory with a single command. Foreign key constraints are detected to insert the data in the correct order
  • Compare two database schemas for differences. The XML output can be transformed into the appropriate SQL ALTER statements using XSLT
  • Compare the data of two databases and generate the necessary SQL statements to migrate one to the other.
  • Supports running SQL scripts in batch mode
  • Supports running in console mode
  • Search text in procedure, view and other sources using a SQL command or a GUI
  • Search for data across all columns in all tables using a SQL command or a GUI
  • Reformatting of SQL Statements
  • Select rows from related tables according to their foreign key definitions
  • Tooltips for INSERT statements to show the corresponding value or column
  • Copy data directly between to database servers using a SQL command or a GUI
  • Macros for frequently used SQL statements
  • Variable substitution in SQL statements including smart prompting for values
  • Auto completion for tables and columns in SQL statements
  • Display database objects and their definitions
  • Display table source
  • Display view, procedure, and trigger source code
  • Display foreign key constraints between tables
  • Full support for BLOB data in query results, SQL statements, export, and import.

Installation

It's written on Java, so you need this software to run it.

First, you must check if you have Java installed on your system:

$ java --version

Then, you need to download the SQL Workbench package:

$ wget https://www.sql-workbench.eu/Workbench-Build124.zip
$ unzip -d sqlworkbench Workbench-Build124.zip

To run it, you must execute the jar file named sqlworkbench.jar using the java command with the jar flag:

$ java -jar sqlworkbench/sqlworkbench.jar

Configuration

To connect to your PostgreSQL database, you need to download the JDBC Driver:

$ wget https://jdbc.postgresql.org/download/postgresql-42.2.5.jar
$ mv postgresql-42.2.5.jar sqlworkbench/

And configure the driver in your SQL Workbench. For this, go to File -> Manage drivers -> Select PostgreSQL and select the driver.

Then, go to File -> Connect window, and complete the Connection Profile information.

After the connection is finished, you can manage your database using it.

The installation is easy but you need to download the driver and configure it manually. Also, the interface is not too friendly.

DBeaver

DBeaver is free and open source universal database tool for developers and database administrators.

Supports all popular databases: MySQL, PostgreSQL, MariaDB, SQLite, Oracle, DB2, SQL Server, Sybase, MS Access, Teradata, Firebird, Derby, etc.

Usability is the main goal of this project, program UI is carefully designed and implemented. It is based on an opensource framework and allows writing of various extensions (plugins). It supports any database having a JDBC driver. There are two versions: Community Edition and Enterprise Edition.

Features

  • Connection manager
  • Metadata browser
  • SQL Editor
  • Data viewer/editor
  • Data/metadata search
  • Database structure compare
  • Data transfer (export/import)
  • ER Diagrams
  • Query Manager
  • Projects
  • Extra views
  • Driver manager
  • Supported relational databases
  • Supported NoSQL databases
  • Supported OSes
  • PostgreSQL
    • Execution plan explain
    • Stored procedures source
    • Views DDL
    • Sequences

Installation

First, you must download the package and install it:

$ wget https://dbeaver.io/files/dbeaver-ce_latest_amd64.deb
$ dpkg -i dbeaver-ce_latest_amd64.deb

And then, just run the following command to open the application:

$ dbeaver

Configuration

When you run the application for the first time, you need to configure your database connection.

So, you need to select PostgreSQL and complete the information.

Then, by selecting Test Connection, you must download the driver files. You should receive the following message after the testing.

When you finish the configuration, you can manage your database by using the DBeaver application.

The installation is, basically, a piece of cake, and the interface looks friendly and intuitive.

Navicat

Navicat for PostgreSQL is an easy-to-use graphical tool for PostgreSQL database development.

This tool will fit all, from beginners to seniors, and fit all tasks from simple queries to development. Connect to local/remote PostgreSQL servers and compatible with cloud databases like Amazon Redshift, Amazon Aurora, Amazon RDS, Google Cloud, Microsoft Azure, Alibaba Cloud, Tencent Cloud and Huawei Cloud, and all PostgreSQL database objects. It's a paid application but you can use the trial version to test it.

Features

  • Supports PostgreSQL 7.3 or later and Cloud services like AWS, Google Cloud or Microsoft Azure among others.
  • Secure connection: SSH/HTTP/SSL
  • Navicat Cloud
  • Data Viewer and Editor
  • SQL Processing
  • Data Modeling
  • Import/Export
  • Data Manipulation
  • Backup/Restore
  • Automation
  • Manage user
  • Server Monitor

Installation

First, we must download the Navicat package and uncompress it.

$ wget http://download3.navicat.com/download/navicat121_pgsql_en_x64.tar.gz
$ tar zxvf navicat121_pgsql_en_x64.tar.gz

Then, we need to run the start_navicat script to start it.

$ cd navicat121_pgsql_en_x64
$ ./start_navicat

This will use Wine to run the Navicat application and it could ask you to install some required dependency during the initialization.

Configuration

When you access the application, you need to create a new connection.

Go to Connection -> PostgreSQL and complete the information.

After this, you can start to use the application to manage your database.

The software runs over Wine on Linux and the trial is for 14 days. The interface looks pretty and friendly.

ClusterControl

ClusterControl supports deployment, management, monitoring and scaling for PostgreSQL.

Each deployed PostgreSQL instance is automatically configured using ClusterControl’s easy to use point-and-click interface.

You can manage backups, run queries, and perform advanced monitoring of all the master and slaves; all with automated failover if something goes wrong.

The automation features inside ClusterControl let you easily setup a PostgreSQL replication environment, where you can add new replication slaves from scratch or use ones that are already configured.

It also allows you to promote masters and rebuild slaves.

There are two versions: Community Edition or Enterprise Edition.

Features

  • Backup Management
  • Monitoring and Alerting
  • Deployment and Scaling
  • Upgrades and Patching
  • Security and Compliance
  • Operational Reporting
  • Configuration Management
  • Automatic Recovery and Repair
  • Performance Management
  • Automated Performance Advisors

Installation

For the installation, you can use the automatic, manual or offline installation.

In this example, we'll use the automatic installation.

You need to download the following script and run it with root privileges on the ClusterControl server:

$ wget http://www.severalnines.com/downloads/cmon/install-cc
$ chmod +x install-cc
$ sudo ./install-cc

Then, you must complete the information like passwords or configuration and it's done.

Configuration

After the installation is finished, you should be able to open the ClusterControl UI on the web browser by using the hostname or IP address of your server, for example: http://192.168.100.191/clustercontrol/

Here you can perform several tasks like deploy, import, monitoring, and even more.

After you have your PostgreSQL cluster imported or deployed by ClusterControl, you can manage it from a complete, friendly web interface.

It runs on a server, so you can use it from everywhere. All the software is installed by ClusterControl, so you don't need to do any installation manually.

Conclusion

In this blog, we reviewed some of the most commons GUI tools for PostgreSQL.

Regardless of the fact that using a GUI tool is not mandatory, it can help you ease some of the daily DBA tasks by providing you with a more friendly way of managing things.

These tools aren't a replacement for the command line (as a DBA you need to master it), but they are extremely helpful and you will really benefit from them.

Shaun M. Thomas: PG Phriday: Terrific Throughput Tracking

$
0
0

Postgres has a lot of built-in information functions that most people don’t know about. Some of these are critical components to identifying replication lag, but what if we could use them for something else, like throughput?

This man’s one simple trick can track actual database throughput; DBAs hate him!

Everybody Knows

Let’s take a look at a common query we might use to track replication lag between a Postgres 11 Primary and one or more Replica nodes.

SELECT client_addr,
       pg_wal_lsn_diff(
           pg_current_wal_lsn(),
           sent_lsn
       ) AS sent_lag,
       pg_wal_lsn_diff(
           pg_current_wal_lsn(),
           write_lsn
       ) AS write_lag,
       pg_wal_lsn_diff(
           pg_current_wal_lsn(),
           flush_lsn
       ) AS flush_lag,
       pg_wal_lsn_diff(
           pg_current_wal_lsn(),
           replay_lsn
       ) AS replay_lag
  FROM pg_stat_replication;

This gives us the number of bytes the Primary has transmitted to remote servers, given a number of different metrics. How much have we sent? Has that data been written to disk? How much has been synced and is thus safe from crashes? How much has actually been replayed on the Postgres data files? For more information on the pg_stat_replication view, check out the documentation.

If we were using slots instead, we might do this:

SELECT slot_name,
       pg_wal_lsn_diff(
         pg_current_wal_lsn(),
         restart_lsn
       ) as restart_lag,
       pg_wal_lsn_diff(
         pg_current_wal_lsn(),
         confirmed_flush_lsn
       ) as flush_lag
  FROM pg_replication_slots;

There is somewhat less information in pg_replication_slots, as it only really tells us the minimum LSN position the Primary needs to retain for that replica. Of course, if that stops advancing while the Primary keeps working, that’s lag we can see even while the replica is disconnected.

This is especially important with replication slots, since they necessarily mean the Primary is retaining WAL files a replica may need. We don’t want the replay lag value to get too high, or the primary node could run out of disk space. That is definitely something we want to monitor.

That’s How it Goes

It’s also a hint as to our database throughput. If we "pin" the value by disconnecting a replica, the value will continue to increase at the same rate the Primary node produces WAL traffic.

But wait a minute; what good is database throughput? It must be pretty useful, as developers have included several indicators in the pg_stat_database view. That view will tell us how many inserts, updates, and deletes a database may have handled, as well as commit versus rollback activity.

Despite all that (and much more), this statistical view won’t tell us anything about data volume, plus it isn’t persistent, and replicas maintain their own stats independently. What if there was a way to determine how active our Primary database is forever, from any node, any time we can take two readings separated by time?

Ah Give or Take a Night or Two

Consider a brand new fresh instance that has just been bootstrapped with initdb. It has processed essentially no transactions, contains no tables, and isn’t currently doing anything. Had we known we’d want to track overall instance activity, we may have called pg_current_wal_lsn() to retrieve the starting LSN.

For example:

SELECT pg_current_wal_lsn();

 pg_current_wal_lsn 
--------------------
 0/1652EC0

In theory, we could use this value on any future call to pg_wal_lsn_diff to obtain the amount of bytes produced by the database instance since its inception. Unfortunately, it’s hardly ever the case we have such an opportunity unless we created the Postgres instance ourselves.

But what is really the difference between 0/1652EC0, and the absolute zero value of 0/0?

SELECT pg_wal_lsn_diff('0/1652EC0', '0/0');

 pg_wal_lsn_diff 
-----------------
        23408320

That’s not even 24MB, which is less than two 16MB WAL files. In that case, we can safely substitute 0/0 and suddenly any execution of pg_current_wal_lsn is trivially transformed into an absolute amount of data produced by our Postgres instance.

And a long stem rose

Let’s initialize a medium 100-scale pgbench instance and check the amount of bytes reported at the end.

SELECT a.total_bytes, 
       (a.total_bytes/1024/1024)::BIGINT AS mbytes
  FROM pg_wal_lsn_diff(pg_current_wal_lsn(), '0/0') a (total_bytes);

 total_bytes | mbytes 
-------------+--------
  1328940592 |   1267

So Postgres has handled about 1267 MB of data since we started. How about after processing a one-minute pgbench test?

 total_bytes | mbytes 
-------------+--------
  1422082032 |   1356

What if we add another index to the pgbench_accounts table?

CREATE INDEX idx_account_balance ON pgbench_accounts (abalance);

 total_bytes | mbytes 
-------------+--------
  1626342784 |   1551

We included that last example to illustrate that this really measures WAL traffic throughput, thus anything that produces WAL traffic will drive the value higher. It’s not just writes to the instance, but anything that modifies its contents. Even read-only transactions will slowly drive this value forward, as these require various database resources including transaction identifiers.

Is there a better cumulative indicator for how much real actual work a Postgres instance is performing?

Before it Blows

Real work is the key to this metric. We could send the query to any number of monitoring tools, and so long as they can compare previous values across time, we now have a total activity chart for our Postgres instance.

Did something perform a large bulk insert? Is client activity producing a steady stream of data and transaction traffic that’s threatening to overwhelm our hardware? Do we need to reevaluate resource allocation to prevent such throughput spikes from negatively impacting overall performance?

These are all questions the knowledge of Postgres throughput can provide. If the graphs show an upward trend, we can even plan for future expansions. It’s a cool piece of data that few, if any, existing monitoring scripts such as check_postgres bother to integrate.

Being proactive is always preferable to the alternative, so adding yet another query to our monitoring toolkit is always a step forward. Don’t forget to watch those charts.

And everybody knows that it’s now or never.


Dan Langille: Moving the email notifications to the new server

$
0
0
Ever since the new server went into production, sometime in 2017, the notification emails, which tell you what has changed, have been coming from the old server. I never did that changeover. The old server was still processing incoming commits, so the notifications were accurate. However, new accounts would not get notifications and changes to [...]

Dan Langille: Fixing a sequence value

$
0
0
Yesterday I copied data from the old production server to the new production server. One thing I missed, but did think about at the time, was updating the sequence used by the table in question. Looking at the table definition: The report_log_id_seq value will be wrong. When the reports run, they will use values for [...]

Adrien Nayrat: pg_sampletolog: An extension to log a sample of statements

$
0
0
This article will introduce you to an extension that I developed in order to log a sample of statements. When a DBA is faced with a performance problem, he will inspect logs, but also the pg_stat_stat_statements view. An expensive query will appear in pg_stat_stat_statements and in the logs if the query exceeds log_min_duration_statement. Thus, the DBA can replay the query, and obtains its execution plan to investigate. To go even further, it is possible to enable the auto_explain extension.

Sebastian Insausti: PostgreSQL High Availability with Master-Slave & Master-Master Architectures

$
0
0

Below is an excerpt from our whitepaper “PostgreSQL Management and Automation with ClusterControl” which can be downloaded for free.


Database servers can work together to allow a second server to take over quickly if the primary server fails (high availability), or to allow several computers to serve the same data (load balancing).

For HA configuration we can have several architectures, but the basic ones would be master-slave and master-master architectures.

PostgreSQL Master-Slave Architectures

These architectures enable us to maintain an master database with one or more standby servers ready to take over operations if the primary server fails. These standby databases will remain synchronized (or almost synchronized) with the master.

The replication between the master and the slaves can be made via SQL statements (logical standbys) or via the internal data structure modifications (physical standbys). PostgreSQL uses a stream of write-ahead log (WAL) records to keep the standby databases synchronized. If the main server fails, the standby contains almost all of the data of the main server, and can be quickly made the new master database server. This can be synchronous or asynchronous and can only be done for the entire database Server.

Setting up streaming replication is a task that requires some steps to be followed thoroughly. For those steps and some more background on this subject, please see: Become a PostgreSQL DBA - How to Setup Streaming Replication for High Availability.

From version 10, PostgreSQL includes the option to setup logical replication.

Logical replication allows a database server to send a stream of data modifications to another server. PostgreSQL logical replication constructs a stream of logical data modifications from the WAL. Logical replication allows the data changes from individual tables to be replicated. It doesn’t require a particular server to be designated as a master or a replica but allows data to flow in multiple directions.

You can find more information regarding logical replication: Blog: An Overview of Logical Replication in PostgreSQL.

To effectively ensure high availability, it is not enough to have a master-slave architecture. We also need to enable some automatic form of failover, so if something fails we can have the smallest possible delay in resuming normal functionality. PostgreSQL does not include an automatic failover mechanism to identify failures on the master database and notify the salve to take ownership, so that will require a little bit of work on the DBA’s side. You should work on a script that includes the pg_ctl promote command, that will promote the slave as a new master. There are also some third party tools for this automation. Many such tools exist and are well integrated with the operating system facilities required for successful failover, such as IP address Migration.

After a failover happens, you need to modify your application accordingly to work with the new master. You will also have only one server working, so re-creation of the master-slave architecture needs to be done, so we get back to the same normal situation that we had before the issue.

Download the Whitepaper Today
 
PostgreSQL Management & Automation with ClusterControl
Learn about what you need to know to deploy, monitor, manage and scale PostgreSQL

PostgreSQL Master-Master Architectures

This architecture provides a way of minimizing the impact of an error in one of the nodes, as the other node can take care of all the traffic, maybe slightly affecting the performance, but never losing functionality. It is also used to accomplish (and maybe this is even a more interesting point) horizontal scalability (scale-out), opposite to the concept of vertical scalability where we add more resources to a server (scale-up).

For implementing this architecture, you will need to use external tools, as this feature is not (yet) natively supported by PostgreSQL.

You must be very careful when choosing a solution for implementing master-master, as there are many different products. A lot of them are still “green” , with few serious users or success cases. Some other projects have, on the other hand, been abandoned, as there are no active maintainers.

For more information on the available tools please refer to: Blog: Top PG Clustering HA Solutions for PostgreSQL.

Load Balancing and Connection Pooling

There are several load balancer tools that can be used to manage the traffic from your application to get the most of your database architecture. In the same way, there are some others that can help you manage the way the application connects to the database, by pooling these connections and reusing them between different requests.

There are some products that are used for both purposes, like the well known pgpool, and some others that will focus in only one of these features, like pgbouncer (connection pooling) and HAProxy (used for load balancing).

Shaun M. Thomas: PG Phriday: PgBouncer or Bust

$
0
0

What is the role of PgBouncer in a Postgres High Availability stack? What even is PgBouncer at the end of the day? Is it a glorified traffic cop, or an integral component critical to the long-term survival of a Postgres deployment?

When we talk about Postgres High Availability, a lot of terms might spring to mind. Replicas, streaming, disaster recovery, fail-over, automation; it’s a ceaseless litany of architectural concepts and methodologies. The real question is: how do we get from Here to There?

The Importance of Proxies

It’s no secret that the application stack must communicate with the database. Regardless of how many layers of decoupling, queues, and atomicity of our implementation, data must eventually be stored for reference. But where is that endpoint? Presuming that write target is Postgres, what ensures the data reaches that desired terminus?

Consider this diagram:

Two nodes with managed proxy layer
Managed Proxy Layer

In this case, it doesn’t matter what type of Standby we’re using. It could be a physical streaming replica, some kind of logical copy, or a fully configured BDR node. Likewise, the Failover Mechanism is equally irrelevant. Whether we rely on repmgr, Patroni, Stolon, Pacemaker, or a haphazard collection of ad-hoc scripts, the important part is that we separate the application from the database through some kind of proxy.

Patroni relies on HAProxy and Stolon has its own proxy implementation, but what about the others? Traditionally PgBouncer fills this role. Without this important component, applications must connect directly to either the Primary or post-promotion Standby. If we’re being brutally honest, the application layer can’t be trusted with that kind of responsibility.

But why is that? Simply stated, we don’t know what the application layer is. In reality, an application is anything capable of connecting to the database. That could be the official software, or it could be a report, or a maintenance script, or a query tool, or any number of other access vectors. Which database node are they connecting to, and does it matter?

The proxy layer is one of the rare opportunities as DBAs that we can control the situation, as it is the city where all roads must lead.

VIP, DNS, and Load Balancers

Rather than implement on an additional tier of software, it’s often easier to rely on the old tried-and-true network infrastructure. A virtual IP address for example, requires no extra resources beyond an IP address carved out of a likely liberally allocated internal VPN. DNS is likewise relatively seamless, having command-line manipulation available through utilities like nsupdate.

VIPs unfortunately have a major drawback that may mean they’re inapplicable for failover to a different DC: the assigned ethernet device must be on the same subnet. So if the address is 10.2.5.18, all nodes that wish to use it should be on the 10.2.5.* network. It’s fairly common to have dedicated subnets per Data Center, meaning they can’t share a single VIP. One possible solution to this is to create a subnet that spans both locations, specifically for sharing IP resources.

Another is to use DNS instead. However, this approach may be even worse in the long run. Because name lookups are relatively slow, various levels of caching are literally built into the protocol, and liberally enforced. These caches may be applied at the switch, the drivers, the operating system, a local daemon, and even the application itself. Each one has an independent copy of the cached value, and any changes to a DNS record are only truly propagated when all of these reflect the modification. As a result, the TTL of a DNS record can be a mere fraction of the time it actually takes for all layers to recognize the new target.

During all of this, it would be unsafe to continue utilizing the database layer for risk of split-brain, so applications must be suspended. Clearly that’s undesirable in most circumstances.

Some companies prefer load balancing hardware. This is a panacea of sorts, since such devices act like a VIP without the subnet restriction. Further, these often have programmable interfaces that allow scripts or other software to reconfigure traffic endpoints. This unfortunately relies on extra budgetary constraints that don’t apply to VIP or DNS solutions, making it a resource that isn’t always available.

Software like PgBouncer acts like a virtual approximation of such hardware, with the additional bonus of understanding the Postgres communication protocol. So long as there’s spare hardware, or even a minimally equipped VM, it’s possible to provide decoupled access to Postgres.

Smooth Transitions

One aspect the network-oriented PgBouncer alternatives ignore, is comprehension of the Postgres communication protocol. This is critically important from a High Availability perspective, because it avoids immediately terminating ongoing transactions during manual switches. As a proxy, PgBouncer can react to transaction state, and consequentially avoid interrupting active sessions.

Specifically, version 1.9 of PgBouncer introduced two new features that make this possible where it wasn’t before. It’s now possible to put a server backend into close_needed state. Normally PgBouncer is configured to be either in session mode, where server backends are assigned directly to client connections until they disconnect, or transaction mode, where backends are assigned to new clients after each transaction commit.

In close_needed state, a client that ends its session while in session mode will also close the server backend. Likewise in transaction mode, the server backend is closed and replaced with a new allocation at the end of the current transaction. Essentially we’re now allowed to mark a server backend as stale and in need of replacement at the earliest opportunity without preventing new connections.

Any configuration modification to PgBouncer that affects connection strings will automatically place the affected servers in close_needed state. It’s also possible to manually set close_needed by connecting to the pgbouncer psuedo-database and issuing a RECONNECT command. The implication here is that PgBouncer can be simultaneously connected to Server A and server B without forcing a hard cutover. This allows the application to transition at its leisure if possible.

The secret sauce however, is the server_fast_close configuration parameter. When enabled, PgBouncer will end server backends in close_needed state, even in session mode, provided the current transaction ends. Ultimately this means any in-progress transactions can at least ROLLBACK or COMMIT before their untimely demise. It also means we can redirect database server traffic without interrupting current activity, and without waiting for the transactions themselves to complete.

Previously without these new features, we could only issue PAUSE and RELOAD, and then wait for all connections to finally end of their own accord, or alternatively end them ourselves. Afterward, we could issue RESUME so traffic could reach the new database server target. Now the redirection is immediate, and any lingering transactions can complete as necessary.

This is the power of directly implementing the Postgres client protocol, and it’s something no generic proxy can deliver.

Always Abstract

At this point, it should be fairly evident what options are available. However, we also strongly recommend implementing an abstraction layer of some kind at all times, even when there is only a single database node. Here’s a short list of reasons why:

  • One node now doesn’t mean one node forever. As needs evolve and the architecture matures, it may be necessary to implement a full High Availability or Disaster Recovery stack.
  • Upgrades don’t care about your uptime requirements. Cross-version software upgrades and hardware replacement upgrades are principally problematic. Don’t get stuck playing Server Musical Chairs.
  • Connection pools can be surprisingly necessary. In a world where micro-architectures rule, sending thousands of heterogeneous connections to a single database server could otherwise lead to disaster.

Some of these are possible with VIPs and similar technology, others are limited to the realm of pooling proxies. The important part is that the abstraction layer itself is present. Such a layer can be replaced as requirements evolve, but direct database connections require some kind of transition phase.

Currently only PgBouncer can act as a drop-in replacement for a direct Postgres connection. Software like HAProxy has a TCP mode that essentially masquerades traffic to Postgres, but it suffers from the problem of unceremonious connection disruption on transition. That in itself isn’t necessarily a roadblock, so long as that limitation is considered during architectural planning.

In the end, some may prefer their Postgres abstraction layer to understand Postgres. Visibility into the communication protocol gives PgBouncer the ability to interact with it. Future versions of PgBouncer could, for example, route traffic based on intent, or stack connection target alternates much like Oracle’s TNS Listener.

Yes, it’s Yet Another VM to maintain. On the other hand, it’s less coordination with all of the other internal and external teams to implement and maintain. We’ve merely placed our database black-box into a slightly larger black-box so we can swap out the contents as necessary. Isn’t that what APIs are for, after all?

Bruce Momjian: Postgres Encryption Maze

$
0
0

This wide-ranging email thread covers many of the challenges of adding encryption to Postgres. There is discussion of:

  • The need to understand the threats you are protecting against, "For anyone to offer a proper solution, you need to say what purpose your encryption will serve."
  • The need for layers of protection
  • The questionable usefulness of storage encryption, "Thus, unless you move your DB server on a regular basis, I can't see the usefulness of whole database encryption (WDE) on a static machine."
  • The value of encrypting network storage, "Having the 'disk' associated with a specific server encrypted can provide some level of protection from another machine which also has access to the underlying infrastructure from being able to access that data."
  • Credit Card industry requirements, "Non-Pubic Information (NPI) data should not be logged nor stored on a physical device in non-encrypted mode."
  • The limits of per-column encryption, "It is extremely unlikely you just want all the data in the database encrypted." (These five emails from another thread, 1,2,3,4,5, also discuss this topic.)
  • The many other database products that support built-in column-level encryption

As you can see, the discussion was all over the map. The Postgres project probably needs to do a better job communicating about these options and their benefits.

Kaarel Moppel: Major feature update for the pgwatch2 Postgres monitoring tool

$
0
0

Again I could make good (hopefully) use of the “slow time” around the turn of the year…and managed to push out another set of features for our Open Source PostgreSQL monitoring tool called pgwatch2 – so a quick overview on changes in this post. Continuing the tradition I’m calling it “Feature Pack 4” as it’s mostly about new features. Git and Docker images carry version number 1.5.0. As our last pgwatch2-related blogpost covered only 1.4.0, I’ll include here also most important stuff from 1.4.5 minor feature release.

Highlight – Monitoring Postgres with Postgres

This is the biggest one this time – finally and quite approprietly for “Postgres-minded” people, there’s now a chance to store all the gathered metrics in Postgres! This of course doesn’t necessarily mean that Postgres is best for storing Time-Series Data although it performs very nicely thanks to JSONB…but in general it’s a good compromise – more disk space (~3-4x) at comparable query times to InfluxDB…but with full power of SQL! Meaning some saved time learning a new (and quite limited) query language. And after all, only a few people are running dozens and dozens of databases so performance is mostly not and issue. And on the plus side we can now ask questions that were previously plainly not possible (no joins, remember) or were only possible by storing some extra columns of data (de-normalizing).

The new functionality is designed for the latest Postgres version of 11, but as people run all kinds of different versions and might not want to set up a new cluster, there is also a legacy mode, that will cost more IO though. In total there are 4 different “schema modes” so that people could optimize their IO based on needs:

  • a separate normal table for each distinct metric (legacy mode)
  • a separate partitioned table for each distinct metric + weekly partitions
  • a separate partitioned table for each distinct metric + separate sub-table for each distinct monitored host + monthly partitions. Best for monitoring 50+ DB-s
  • custom mode – all data inserted into a single table where it can be re-routed with a trigger for example.

For the partitioned modes there is also automatic “retention management” – by default 1 month of data is kept. Partitions live in a separate “subpartitions” schema, top level tables are in “public”.

To test it out fire up a Docker container with something like:

# assuming "postgres" is superuser and auto-creating metrics fetching helpers
docker run --rm --name pw2 -p 3000:3000 -e PW2_ADHOC_CONN_STR="postgresql://postgres@mydb.com/mydb" -e PW2_ADHOC_CREATE_HELPERS=1 cybertec/pgwatch2-postgres
# After 5min open up Grafana at 0.0.0.0:3000 and start evaluating what's going on in your database...

Call for feedback

And as always, please do let us know on Github if you’re still missing something in the tool or are experiencing difficulties – any feedback would be highly appreciated!

Project Github link – here.
Full changelog – here.

Most important changes for v1.5.0

  • Postgres support for metrics storage

There are multiple (4) storage schema types supported so even legacy PG versions and custom needs should be covered. PG 11+ needed though to use time-based partitioning. Comes with automatic “retention policy” enforcement (given the gatherer is running).

  • Test data generation

A by-product of testing Postgres metrics storage, it helps to quickly estimate metrics data volumes under real life conditions to see if your hardware or selected storage “schema type” can handle the amount of planned metrics. Metrics will be fetched one time from a user specified DB and then data inserted multiple times with correct intervals for the simulated host count. There are also some scripts provided to generate bigger data amounts faster and to test typical dashboard queries speed.

  • Connection string password encryption/decryption with AES-GCM-256

Previously monitoring user passwords where stored in plain text for both “config DB” and “YAML” mode. Now an encryption key or keyfile can be provided to the Gatherer and the Web UI to transparently encypt passwords. Default will remain “plain-text” as pgwatch2 is assumably mostly used in safe environments or for ad-hoc troubleshooting and it’s just more convenient so.

  • Libpq SSLMODE-s ‘verify-ca’ and ‘verify-full’ support

Previously only ‘disabled’ and ‘require’ were supported. Certs need to be present on the machine where the gatherer is running.

  • Support for declaring metrics as Standby-only or Master-only

For example the “pg_stat_database_conflicts” view is always empty on a primary so it makes no sense to query it there. This should result in less errors both in Postgres and pgwatch2 logs.

  • De-coupling of metrics from the “public” schema

Previously “public” schema for extensions and “metric fetching helpers” was assumed, but now no such assumption is made, allowing any schema – user just needs to make sure that the monitoring role has it’s “search_path” correctly set. Also no more “public” grants for helpers, only for the monitoring role.

  • SystemD support + service files

Paths need to be adjusted manually both for the Gatherer and Web UI. Thanks @slardiere!

  • Gatherer performance improvements

50% less internal message passing over channels meaning much better performance when monitoring 50+ DB-s.

  • Reduced error messages when monitored Dbs are down

Also when metric definitions are not found etc, one error per hour only.

  • Various metrics fixes and additions

Some new metrics (“wal_size”) added and “db_size” split up from “db_stats”. Gathering intervals for some “not so used” metrics have also been increased in the preset configs.

Most important changes for v1.4.5

  • Parallel metric fetching for a single monitored DB

Two different metric queries can now run simultaneously on a single monitored DB.

  • New “Health-check” dashboard

All most important healt indicators on a singe page, with green / yellow / red indicators.

  • New “Index overview” dashboard

Top scanned, un-used, biggest, duplicate and invalid indexes overview.

  • New “Tables top” dashboard

Top-N by size and growth/scan and INSERT/UPDATE/DELETE rates.

Screenshots of new Dashboards

“Health-check” dashboard
Health-check dashboard

“Index overview” dashboard
Index overview dashboard

“Top tables” dashboard
Top tables dashboard

The post Major feature update for the pgwatch2 Postgres monitoring tool appeared first on Cybertec.


Dave Cramer: A Guide to Building an Active-Active PostgreSQL Cluster

$
0
0

One of the toughest challenges facing database engineers today is ensuring their data is always accessible so they can meet the high-availability  requirements for their applications.

While this problem may seem trivial in the world of applications where one can have many instances behind geographically distributed load balancers, in the database world where there is only one version of the data globally, the problem faces many obstacles.

PostgreSQL replication has advanced considerably in recent major releases, including continuous improvements to streaming replication and the addition of logical replication in PostgreSQL 10. While these capabilities represent important enhancements to PostgreSQL, enabling users to address a wide variety of clustered architectures, they do not (easily) address the use cases where the application requires access to an updatable database in two or more geographic regions - often referred to as an "active-active" cluster.

More specifically, an active-active cluster is one where the application can write to any instance in the cluster and the data will be written to all of the instances in the cluster, enabling each instance in the cluster to be used to:


  • Provide near zero downtime as the new instance is already in a read/write state; there is no need to reconfigure it.
  • Provide near zero downtime upgrades from one version to another
  • Improve latency for users in geographically distributed clusters. By providing an instance physically closer to the user latency is reduced.

While there are a number of proprietary solutions that attempt to address active-active PostgreSQL requirements, this post and a series to follow provides users with potential reference architectures and configurations that enable active-active PostgreSQL configurations using entirely open source software.

This post is of course only one approach to deploying an active-active PostgreSQL cluster.  There are other ways to deploy an active-active setup with PostgreSQL.  I will cover some ways to do this in the future - stay tuned!

Pavel Stehule: plpgsql_check - new report for code coverage ratio calculation

$
0
0
Few months ago I integrated a profiler into plpgsql_check.

The result of prifiling is line oriented:

postgres=# select lineno, avg_time, source from plpgsql_profiler_function_tb('fx(int)');
┌────────┬──────────┬───────────────────────────────────────────────────────────────────┐
│ lineno │ avg_time │ source │
╞════════╪══════════╪═══════════════════════════════════════════════════════════════════╡
│ 1 │ │ │
│ 2 │ │ declare result int = 0; │
│ 3 │ 0.075 │ begin │
│ 4 │ 0.202 │ for i in 1..$1 loop │
│ 5 │ 0.005 │ select result + i into result; select result + i into result; │
│ 6 │ │ end loop; │
│ 7 │ 0 │ return result; │
│ 8 │ │ end; │
└────────┴──────────┴───────────────────────────────────────────────────────────────────┘
(9 rows)

This format is well readable, but it is not practical for calculation of code coverage metrics. So this week I wrote new function, that produce
report based on commands:

        CREATE OR REPLACE FUNCTION public.fx1(a integer)
RETURNS integer
LANGUAGE plpgsql
1 AS $function$
2 begin
3 if a > 10 then
4 raise notice 'ahoj';
5 return -1;
6 else
7 raise notice 'nazdar';
8 return 1;
9 end if;
10 end;
11 $function$

postgres=# select stmtid, parent_stmtid, parent_note, lineno, exec_stmts, stmtname
from plpgsql_profiler_function_statements_tb('fx1');
┌────────┬───────────────┬─────────────┬────────┬────────────┬─────────────────┐
│ stmtid │ parent_stmtid │ parent_note │ lineno │ exec_stmts │ stmtname │
╞════════╪═══════════════╪═════════════╪════════╪════════════╪═════════════════╡
│ 0 │ ∅ │ ∅ │ 2 │ 0 │ statement block │
│ 1 │ 0 │ body │ 3 │ 0 │ IF │
│ 2 │ 1 │ then body │ 4 │ 0 │ RAISE │
│ 3 │ 1 │ then body │ 5 │ 0 │ RETURN │
│ 4 │ 1 │ else body │ 7 │ 0 │ RAISE │
│ 5 │ 1 │ else body │ 8 │ 0 │ RETURN │
└────────┴───────────────┴─────────────┴────────┴────────────┴─────────────────┘
(6 rows)

Now, it should not be too difficult to calculate (by SQL) some coverage metrics.

Liaqat Andrabi: Webinar: Banking on Postgres – Financial Application Considerations [Follow up]

$
0
0

The demand for PostgreSQL within the financial industry has been rapidly increasing in the recent years; mainly due to reduction in licensing costs, better choice of open source tools, and the robust enterprise features that PostgreSQL provides.

2ndQuadrant hosted the “Banking on Postgres” webinar to discuss attributes of financial databases based on Postgres, configuration processes, hardware needs, availability, backups, and more.

The webinar was presented by Shaun Thomas, Principal Consultant at 2ndQuadrant. Those who weren’t able to attend the live event can now view the recording here.

For any questions or comments regarding Postgres-BDR, please send an email to info@2ndQuadrant.com.

Bruce Momjian: Limiting Superuser Activity

$
0
0

This interesting email thread explores the question of how much you can prevent or detect unauthorized database superuser activity. The main conclusions from the thread are:

  • It is impossible to restrict database administrator access without hindering their ability to perform their jobs
  • Monitoring superuser activity is the most reasonable way to detect and hopefully discourage unauthorized activity
  • Monitoring includes:
    • Assign a separate account to each administrator for auditing purposes; do not use generic/shared accounts
    • Use an auditing tool to record database activity, e.g., pgAudit
    • Use syslog to send database logs to a computer not under database administrators' control
    • Record all shell command activity in a similar way

There is also a helpful summary email.

Keith Fiske: Managing Transaction ID Exhaustion (Wraparound) in PostgreSQL

$
0
0

One of the most critical topics to understand when administering a PostgresSQL database is the concept of transaction IDs (TXID) and that they can be exhausted if not monitored properly. However, this blog post isn't going to go into the details of what it TXID exhaustion actually is. The Routine Vacuuming section of the documentation is probably one of the most important to read and understand so I will refer you there. What this blog post is going to cover is an easy way to monitor for it and what can be done to prevent it ever being a problem.

Viewing all 9665 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>