<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PostgreSQL on Dimitri Fontaine</title><link>https://tapoueh.org/categories/postgresql/</link><description>Recent content in PostgreSQL on Dimitri Fontaine</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 06 Oct 2026 13:45:23 +0200</lastBuildDate><atom:link href="https://tapoueh.org/categories/postgresql/index.xml" rel="self" type="application/rss+xml"/><item><title>Consolidating databases with Postgres logical replication</title><link>https://tapoueh.org/blog/2026/10/consolidating-databases-with-postgres-logical-replication/</link><pubDate>Tue, 06 Oct 2026 13:45:23 +0200</pubDate><guid>https://tapoueh.org/blog/2026/10/consolidating-databases-with-postgres-logical-replication/</guid><description>&lt;p&gt;This is part 2 of a series about Postgres logical replication use-cases,
and about how the feature set has evolved over the past ten years and ten
releases, one architecture at a time.
&lt;a href="https://tapoueh.org/blog/2026/09/ten-years-of-postgres-logical-replication/"&gt;Part 1&lt;/a&gt; built a
hub-and-workers system for write scalability and has the table of what
each release added, which this post assumes. Part 3 covers a zero-downtime
major upgrade.&lt;/p&gt;</description></item><item><title>Ten years of Postgres logical replication</title><link>https://tapoueh.org/blog/2026/09/ten-years-of-postgres-logical-replication/</link><pubDate>Tue, 22 Sep 2026 17:26:01 +0200</pubDate><guid>https://tapoueh.org/blog/2026/09/ten-years-of-postgres-logical-replication/</guid><description>&lt;p&gt;A long time ago I ran a write-heavy system on a hub and a handful of workers.
Each worker took a share of the application traffic and wrote events
locally. The hub owned the reference data (customers, plans, prices),
pushed it down to the workers, and pulled every worker&amp;rsquo;s events back up to
compute the invoices. The plumbing was Londiste and PgQ: triggers on every
table, a queue per node, a ticker, and a Python daemon per hop. It worked,
and it was a lot of moving parts to explain to anyone new.&lt;/p&gt;
&lt;p&gt;Postgres 10 shipped logical replication in 2017, and 19 is the tenth release
that has it. Every release since Postgres 10 has taken a piece of that
plumbing and made it a line of SQL.&lt;/p&gt;
&lt;p&gt;This is the first article in a series about Postgres logical replication
use-cases, and about how the feature set has evolved over the past ten
years and ten releases. The question is the application developer&amp;rsquo;s one,
not the DBA&amp;rsquo;s: &lt;em&gt;which architectures can I deploy with Postgres core alone
today, what does each release change about that, and where do I still need
something else?&lt;/em&gt; I built three architectures for real, across three posts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Hub and workers&lt;/strong&gt;, spreading the write load across servers — this post.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Consolidation&lt;/strong&gt;: many databases, different applications and schemas,
into one, then re-exported as a change stream for a CDC consumer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero-downtime major upgrade&lt;/strong&gt;, with a way back.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A fourth post, covering what is left out of this series in less detail —
geo-replication, BDR-style multi-active setups, plain CDC and triggers — is
also planned.&lt;/p&gt;</description></item><item><title>Plan Advice in PostgreSQL 19</title><link>https://tapoueh.org/blog/2026/09/plan-advice-in-postgresql-19/</link><pubDate>Tue, 15 Sep 2026 18:27:53 +0200</pubDate><guid>https://tapoueh.org/blog/2026/09/plan-advice-in-postgresql-19/</guid><description>&lt;p&gt;There is a conversation that happens in every PostgreSQL shop eventually. A
query that has been fine for a year gets slow overnight. Nothing was
deployed. The data grew a little, &lt;code&gt;ANALYZE&lt;/code&gt; ran, and the planner — entirely
reasonably, on the numbers it had — picked a different plan. The old plan
was better. You would like it back.&lt;/p&gt;
&lt;p&gt;PostgreSQL 19 ships two new modules for exactly this: &lt;code&gt;pg_plan_advice&lt;/code&gt;,
which can read a plan back out as a string and enforce it later, and
&lt;code&gt;pg_stash_advice&lt;/code&gt;, which keeps those strings keyed by query id and applies
them automatically.&lt;/p&gt;
&lt;aside class="lab-note"&gt;&lt;span class="lab-mark" aria-hidden="true"&gt;▸&lt;/span&gt;&lt;div&gt;Every query below ran against &lt;a href="https://theartofpostgresql.com/lab/"&gt;the Lab&lt;/a&gt;,
the free dataset bundle used throughout this blog, on PostgreSQL 19 Beta 3:
&lt;code&gt;POSTGRES_VERSION=19beta3 PG_MAJOR=19 docker compose up&lt;/code&gt;. Both modules are
contrib, and the Lab image ships them; nothing below runs a &lt;code&gt;LOAD&lt;/code&gt; to
enable them, because the server already has them — &lt;code&gt;pg_plan_advice&lt;/code&gt; in
&lt;code&gt;session_preload_libraries&lt;/code&gt;, &lt;code&gt;pg_stash_advice&lt;/code&gt; in
&lt;code&gt;shared_preload_libraries&lt;/code&gt; (it can survive a restart, which needs
loading that way). One line each in &lt;code&gt;postgresql.conf&lt;/code&gt;, or the equivalent
server-start flag, and you&amp;rsquo;re done. &lt;code&gt;pg_stash_advice&lt;/code&gt; still needs its own
&lt;code&gt;CREATE EXTENSION&lt;/code&gt;, further down, for its SQL functions — that&amp;rsquo;s
independent of how the module itself got loaded.&lt;/div&gt;&lt;/aside&gt;</description></item><item><title>Getting Ready for PostgreSQL 19</title><link>https://tapoueh.org/blog/2026/09/getting-ready-for-postgresql-19/</link><pubDate>Thu, 03 Sep 2026 15:09:30 +0200</pubDate><guid>https://tapoueh.org/blog/2026/09/getting-ready-for-postgresql-19/</guid><description>&lt;p&gt;PostgreSQL 19 Beta 3 shipped on August 13, 2026, and &lt;a href="https://www.postgresql.org/docs/19/release-19.html"&gt;the release
notes&lt;/a&gt; have been filled
in as of 2026-07-18 — still marked subject to change, and the GA date isn&amp;rsquo;t
announced yet, but following the project&amp;rsquo;s usual September/October cadence
general availability should land within the next few weeks. That makes now
the right time to read through what&amp;rsquo;s changing, the same way I did for
&lt;a href="https://tapoueh.org/blog/2026/07/sql-improvements-in-postgresql-1118-a-personal-selection/"&gt;PostgreSQL 11 through 18 a few weeks
ago&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is not a changelog dump. It&amp;rsquo;s the subset of PG 19 I think is worth
knowing about before you upgrade: a handful of compatibility breaks that
will bite people who don&amp;rsquo;t read release notes, and the SQL-level additions
I found genuinely useful once I started poking at them. Every query below
ran against a real PostgreSQL 19 Beta 3 instance — no hand-waving about
syntax that might work.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update, 21 September 2026.&lt;/strong&gt; Five features below have been withdrawn from
PostgreSQL 19 since this went out: &lt;code&gt;MERGE PARTITIONS&lt;/code&gt; and SQL/PGQ (already
marked in their own sections), &lt;code&gt;FOR PORTION OF&lt;/code&gt; on 15 September, the
&lt;code&gt;pg_get_*_ddl()&lt;/code&gt; functions on 12 September, and — from the watch list at the
end — online data checksums on 16 September. Each section keeps what I ran on
Beta 3 and now says what happened to it. The &lt;code&gt;pg_get_*_ddl()&lt;/code&gt; functions and
online checksums came out of the 19 branch only and are still in the
development branch for 20; the other three came out of both. Everything else
in this article is still in the release branch.&lt;/p&gt;
&lt;aside class="lab-note"&gt;&lt;span class="lab-mark" aria-hidden="true"&gt;▸&lt;/span&gt;&lt;div&gt;Every query in this article ran against &lt;a href="https://theartofpostgresql.com/lab/"&gt;the Lab&lt;/a&gt;, the same free dataset bundle used in the rest of this blog (F1 data, geopolitical data, music data, and more), pinned to a real PostgreSQL 19 Beta 3 instance. PG 19 support isn&amp;rsquo;t the Lab&amp;rsquo;s default yet, but there is a prebuilt beta image on the registry, for both &lt;code&gt;linux/amd64&lt;/code&gt; and &lt;code&gt;linux/arm64&lt;/code&gt; — so &lt;code&gt;POSTGRES_VERSION=19beta3 PG_MAJOR=19 docker compose up&lt;/code&gt; pulls it rather than building anything, and every query below ran on it. One caveat added after publication: the image behind that tag has since been rebuilt, and the rebuild crashes the server on every &lt;code&gt;FOR PORTION OF&lt;/code&gt; statement I tried; the captures in this article are from the original build. (&lt;code&gt;PG_MAJOR&lt;/code&gt; only matters if Compose ends up building; it costs nothing to set.) Plain &lt;code&gt;docker compose up&lt;/code&gt; still pulls the PG 16 image, and stays the default until 19 reaches general availability.&lt;/div&gt;&lt;/aside&gt;</description></item><item><title>Introducing YeSQL: Practical PostgreSQL, One Concept at a Time</title><link>https://tapoueh.org/blog/2026/08/introducing-yesql-practical-postgresql-one-concept-at-a-time/</link><pubDate>Tue, 18 Aug 2026 10:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2026/08/introducing-yesql-practical-postgresql-one-concept-at-a-time/</guid><description>&lt;p&gt;I&amp;rsquo;m happy to share something new: &lt;a href="https://theartofpostgresql.com/yesql/"&gt;YeSQL&lt;/a&gt;
is live, a free set of 24 short PostgreSQL lessons — one concept, one
runnable query, real data, no signup. It&amp;rsquo;s free to use today, and it&amp;rsquo;s also
a prototype for something I&amp;rsquo;ve wanted to build for a while: making every
query in &lt;em&gt;The Art of PostgreSQL&lt;/em&gt; runnable, right on the page.&lt;/p&gt;</description></item><item><title>Introducing sqlfmt: an SQL gofmt-style formatter</title><link>https://tapoueh.org/blog/2026/08/introducing-sqlfmt-an-sql-gofmt-style-formatter/</link><pubDate>Tue, 11 Aug 2026 14:30:37 +0200</pubDate><guid>https://tapoueh.org/blog/2026/08/introducing-sqlfmt-an-sql-gofmt-style-formatter/</guid><description>&lt;p&gt;Formatting SQL tends to bring some of the same questions again and again:
should we uppercase clause keywords? should we put the separating comma at
the start of a line to ease refactoring? how to align the SQL clauses with
one-another?&lt;/p&gt;
&lt;p&gt;Over the years I have grown my own SQL style and didn&amp;rsquo;t find tooling that
would implement it. Also, I&amp;rsquo;ve been asked here and there if there is a tool
that would replicate &lt;a href="https://theartofpostgresql.com"&gt;The Art of PostgreSQL&lt;/a&gt;
SQL indentation style&amp;hellip; and now there is finally a good answer to that
question!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/dimitri/sqlfmt"&gt;sqlfmt&lt;/a&gt; is a &lt;code&gt;gofmt&lt;/code&gt;-style formatter
that implements my own favorite SQL indentation style. One opinionated
style, no configuration knobs. Run it, commit the result, move on.&lt;/p&gt;</description></item><item><title>SQL Improvements in PostgreSQL 11–18: A Personal Selection</title><link>https://tapoueh.org/blog/2026/07/sql-improvements-in-postgresql-1118-a-personal-selection/</link><pubDate>Tue, 28 Jul 2026 16:39:25 +0200</pubDate><guid>https://tapoueh.org/blog/2026/07/sql-improvements-in-postgresql-1118-a-personal-selection/</guid><description>&lt;p&gt;Seven major versions of PostgreSQL shipped between 2018 and 2025, one per
year without exception, and each with a changelog of 150 to 200 user-visible changes. Each release covers a broad canvas — performance, replication, administration,
and security — but every one of them also advanced the SQL layer, filling gaps
in the standard, adding missing functionality, or cleaning up long-standing
rough edges. Working through the new edition of &lt;em&gt;The Art of PostgreSQL&lt;/em&gt; forced me
to catalogue them all; this is my selection of the features I kept reaching for
while rewriting the examples. I hope it&amp;rsquo;s useful beyond that context —
organized by theme, with the version each feature landed in.&lt;/p&gt;
&lt;aside class="lab-note"&gt;&lt;span class="lab-mark" aria-hidden="true"&gt;▸&lt;/span&gt;&lt;div&gt;All queries in this article run against &lt;a href="https://theartofpostgresql.com/lab/"&gt;the Lab&lt;/a&gt;, a free dataset bundle that includes the F1 database, geopolitical data, music data, and more — so you can try every example yourself. The Lab is a &lt;code&gt;docker compose up&lt;/code&gt; away: it starts PostgreSQL with all datasets loaded and a query UI web app that runs in your browser, with EXPLAIN plan diagrams, and SVG rendering for PostGIS results on geo queries.&lt;/div&gt;&lt;/aside&gt;

&lt;p&gt;To get a sense of where the community actually puts its effort,
&lt;a href="https://github.com/nori-shinoda/documents/"&gt;Noriyoshi Shinoda&lt;/a&gt; of
Hewlett-Packard Enterprise Japan has been publishing a meticulous
&amp;ldquo;PostgreSQL New Features with Examples&amp;rdquo; series for every major release
since version 9.4 — each edition catalogues every user-visible change with
a working code example. Counting his categories across PG 11–18 gives a
clear picture of contributor priorities:&lt;/p&gt;
&lt;figure class="tbl-fig"&gt;
 &lt;div class="tbl-wrap"&gt;&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Release&lt;/th&gt;
					&lt;th style="text-align: right"&gt;SQL&lt;/th&gt;
					&lt;th style="text-align: right"&gt;Performance&lt;/th&gt;
					&lt;th style="text-align: right"&gt;Admin &amp;amp; Ops&lt;/th&gt;
					&lt;th style="text-align: right"&gt;Replication&lt;/th&gt;
					&lt;th style="text-align: right"&gt;Security&lt;/th&gt;
					&lt;th style="text-align: right"&gt;Other&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 11&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 12&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
					&lt;td style="text-align: right"&gt;7&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 13&lt;/td&gt;
					&lt;td style="text-align: right"&gt;7&lt;/td&gt;
					&lt;td style="text-align: right"&gt;8&lt;/td&gt;
					&lt;td style="text-align: right"&gt;10&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 14&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;7&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 15&lt;/td&gt;
					&lt;td style="text-align: right"&gt;2&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;8&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 16&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
					&lt;td style="text-align: right"&gt;8&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;7&lt;/td&gt;
					&lt;td style="text-align: right"&gt;8&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 17&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
					&lt;td style="text-align: right"&gt;7&lt;/td&gt;
					&lt;td style="text-align: right"&gt;8&lt;/td&gt;
					&lt;td style="text-align: right"&gt;8&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;6&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;PG 18&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;4&lt;/td&gt;
					&lt;td style="text-align: right"&gt;3&lt;/td&gt;
					&lt;td style="text-align: right"&gt;2&lt;/td&gt;
					&lt;td style="text-align: right"&gt;5&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;strong&gt;Sum&lt;/strong&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;&lt;strong&gt;48&lt;/strong&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;&lt;strong&gt;54&lt;/strong&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;&lt;strong&gt;38&lt;/strong&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;&lt;strong&gt;31&lt;/strong&gt;&lt;/td&gt;
					&lt;td style="text-align: right"&gt;&lt;strong&gt;46&lt;/strong&gt;&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;figcaption&gt;New features by category per release (Shinoda count)&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;SQL is the smallest category. Admin &amp;amp; Ops leads across the whole period,
followed by Performance — which reflects who funds the project: Amazon
(Aurora), Google (AlloyDB), and Microsoft (Azure) all have strong commercial
interests in PostgreSQL being easy to operate, scale, and replicate at cloud
scale. Replication &amp;amp; HA shows the steepest growth trajectory, climbing from
3 features in PG 11 to 8 in PG 17, tracking the same commercial priorities.
The framing of this article is deliberately SQL-centric: execution strategy, query syntax,
data types, schema modeling, and DML. Administration, replication, and
authentication improvements are real too; a few that struck me as particularly worth knowing about are collected at the end.&lt;/p&gt;</description></item><item><title>pgcopydb v0.18</title><link>https://tapoueh.org/blog/2026/07/pgcopydb-v0.18/</link><pubDate>Wed, 01 Jul 2026 16:05:56 +0200</pubDate><guid>https://tapoueh.org/blog/2026/07/pgcopydb-v0.18/</guid><description>&lt;p&gt;Hot off the press: &lt;a href="https://github.com/dimitri/pgcopydb/releases/tag/v0.18"&gt;pgcopydb
v0.18&lt;/a&gt; is out!&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s the biggest release the project has had — 88 commits since v0.17, which
shipped in August 2024. I took a break from my Open Source responsibilities
for a while, because I was lacking employer support to make it happen.&lt;/p&gt;
&lt;h2 id="what-is-pgcopydb"&gt;What is pgcopydb&lt;/h2&gt;
&lt;p&gt;pgcopydb copies a PostgreSQL database to another PostgreSQL server, as fast
as possible when physical file copy isn&amp;rsquo;t available. It parallelises the
COPY across all tables simultaneously, builds indexes in parallel after data
is loaded, and supports Change Data Capture via logical replication for
minimal-downtime migrations. It is designed to be restartable: state is
tracked in a local SQLite catalog so an interrupted run can resume where it
left off.&lt;/p&gt;
&lt;h2 id="headline-features-of-pgcopydb-v018"&gt;Headline Features of pgcopydb v0.18&lt;/h2&gt;
&lt;p&gt;v0.18 brings compatibility with PostgreSQL 16, 17, and 18; a pgoutput-default
CDC engine with significant reliability and performance improvements;
regular-expression-based filtering; Citus-to-Citus migration support; and
24 bug fixes.&lt;/p&gt;</description></item><item><title>Postgres HA: roles are dynamic</title><link>https://tapoueh.org/blog/2021/12/postgres-ha-roles-are-dynamic/</link><pubDate>Tue, 14 Dec 2021 22:36:36 +0100</pubDate><guid>https://tapoueh.org/blog/2021/12/postgres-ha-roles-are-dynamic/</guid><description>&lt;p&gt;High-Availability comes with some impact on your architecture choices, in
particular when applied to RDBMS such as Postgres. One such impact is the
idea of a failover. When implementing database HA, it is usually expected
that both the service and the data are maintained available in the face of
operational faults. The most common way to implement resilience includes
automated (or manual) failover, where a new primary is elected among a list
of standby nodes.&lt;/p&gt;
&lt;p&gt;In other words, as soon as Postgres High-Availability is implemented, the
roles of your Postgres nodes are dynamic. The fact that a given node is a
primary or a standby at any given point in time ceases to be relevant to
understanding your architecture. In fact, the only thing that&amp;rsquo;s now given
about the role of a node is that it will change. Otherwise you don&amp;rsquo;t have
failover capability, and then, you probably don&amp;rsquo;t have HA in the first
place, right?&lt;/p&gt;
&lt;p&gt;In this article we are going to try and understand what having dynamic roles
for Postgres nodes in a HA system means.&lt;/p&gt;</description></item><item><title>An introduction to the pg_auto_failover project</title><link>https://tapoueh.org/blog/2021/11/an-introduction-to-the-pg_auto_failover-project/</link><pubDate>Wed, 10 Nov 2021 17:11:29 +0100</pubDate><guid>https://tapoueh.org/blog/2021/11/an-introduction-to-the-pg_auto_failover-project/</guid><description>&lt;p&gt;We just released &lt;a href="https://github.com/citusdata/pg_auto_failover/releases/tag/v1.6.3"&gt;pg_auto_failover version
1.6.3&lt;/a&gt; on
GitHub, and the binary packages should be already available at the usual
PGDG and CitusData places, both for debian based distributions and RPM based
distributions too.&lt;/p&gt;
&lt;p&gt;This article is an introduction to the pg_auto_failover project: we answer
the &lt;em&gt;Five W&lt;/em&gt; questions, starting with why does the project exist in the
first place?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; pg_auto_failover is an awesome project. It fills the gap between
&lt;em&gt;“Postgres is awesome, makes developping my application so much easier, it
solves so many problems for me!”&lt;/em&gt; and the next step &lt;em&gt;“so, how do I run
Postgres in Production?”&lt;/em&gt;. If you&amp;rsquo;re not sure how to bridge that gap
yourself, how to deploy your first production system with automated
failover, then pg_auto_failover is for you. It is simple to use, user
friendly, and well documented. &lt;strong&gt;Star it&lt;/strong&gt; on the &lt;a href="https://github.com/citusdata/pg_auto_failover"&gt;pg_auto_failover GitHub
repository&lt;/a&gt; and get started
today. Consider contributing to the project, it is fully Open Source, and
you are welcome to join us.&lt;/p&gt;
&lt;p&gt;Buckle up, our guide tour is starting now!&lt;/p&gt;</description></item><item><title>PostgreSQL as a Microservice</title><link>https://tapoueh.org/blog/2021/06/postgresql-as-a-microservice/</link><pubDate>Tue, 08 Jun 2021 13:40:00 +0200</pubDate><guid>https://tapoueh.org/blog/2021/06/postgresql-as-a-microservice/</guid><description>&lt;p&gt;The &lt;a href="https://www.clever-cloud.com/fr/podcast/"&gt;MACI&lt;/a&gt; French podcast honoured
me with an invitation to a guest appearance on their weekly schedule. As you
can imagine, we talked about many things related to PostgreSQL&amp;hellip; and also
reacted to some newsworthy articles carefully curated by the MACI team. One
of the topics we discussed in the podcast started with looking at PostgreSQL
through the angle of it being one of the microservices that your application
would be composed of.&lt;/p&gt;</description></item><item><title>2020: Online Conferences</title><link>https://tapoueh.org/blog/2020/11/2020-online-conferences/</link><pubDate>Fri, 27 Nov 2020 13:10:00 +0100</pubDate><guid>https://tapoueh.org/blog/2020/11/2020-online-conferences/</guid><description>&lt;p&gt;Among a lot of other changes, the year 2020 brings Online Conferences to us.
In the Postgres community too we now record our talks at home and send a
video file to be playedto a virtual audience, and sometimes shared later in
a platform online.&lt;/p&gt;
&lt;p&gt;So this year I did participate in &lt;a href="https://www.postgresvision.com/"&gt;Postgres Vision
2020&lt;/a&gt; where I did deliver a talk about &lt;a href="https://sched.co/cTyt"&gt;The
Art of PostgreSQL&lt;/a&gt;. This a talk all about the book
that I have written and self-publish at &lt;a href="https://theartofpostgresql.com"&gt;The Art of
PostgreSQL&lt;/a&gt;: learn how to turn thousands of
lines of code into simple SQL queries.&lt;/p&gt;</description></item><item><title>List PostgreSQL tables using extensions</title><link>https://tapoueh.org/blog/2019/11/list-postgresql-tables-using-extensions/</link><pubDate>Tue, 12 Nov 2019 19:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2019/11/list-postgresql-tables-using-extensions/</guid><description>&lt;p&gt;Postgres has extensions, and that&amp;rsquo;s awesome! Of course as the author of
&lt;code&gt;CREATE EXTENSION&lt;/code&gt; I&amp;rsquo;m a little biased… just remember that the ability to
extend Postgres is way more than just this command. The whole database
system has been design from the ground up to allow for extensibility. Parts
of the design is to be found in the way you can register new objects at
runtime: functions of course, and also data types, operators, index support
structures such as operator classes and families, even index access methods!&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article shows a query that you can use to list those tables in your
schemas that are using a data type which is provided by an extension.&lt;/p&gt;</description></item><item><title>Postgres Connection Strings and psql</title><link>https://tapoueh.org/blog/2019/09/postgres-connection-strings-and-psql/</link><pubDate>Wed, 04 Sep 2019 11:38:02 +0200</pubDate><guid>https://tapoueh.org/blog/2019/09/postgres-connection-strings-and-psql/</guid><description>&lt;p&gt;&lt;a href="https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING"&gt;PostgreSQL connection
strings&lt;/a&gt;
embedded in your application can take two different forms: the key-value
notation or the &lt;code&gt;postgresql://&lt;/code&gt; URI scheme. When it comes to using &lt;code&gt;psql&lt;/code&gt;
though, another form of connection string is introduced, with command line
options &lt;code&gt;-h -p -U&lt;/code&gt; and environment variable support.&lt;/p&gt;
&lt;p&gt;In this short article you will learn that you can use either of the three
different forms in &lt;code&gt;psql&lt;/code&gt; and thus easily copy &amp;amp; paste you application
connection string right at the console to test it!&lt;/p&gt;</description></item><item><title>The Art Of PostgreSQL</title><link>https://tapoueh.org/blog/2019/08/the-art-of-postgresql/</link><pubDate>Mon, 26 Aug 2019 10:15:00 +0100</pubDate><guid>https://tapoueh.org/blog/2019/08/the-art-of-postgresql/</guid><description>&lt;p&gt;I did it again! Today I am releasing the new edition of my book, with a new
title: “The Art of PostgreSQL”. I&amp;rsquo;m very happy (and quite excited) to
declare my book as &lt;em&gt;Generally Available&lt;/em&gt;!&lt;/p&gt;
&lt;figure class="right"&gt;&lt;a href="https://theartofpostgresql.com"&gt;&lt;img src="https://tapoueh.org/img/TAOPCoverTablet.png"&gt;&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;a href="https://theartofpostgresql.com"&gt;The Art of PostgreSQL&lt;/a&gt; is the new edition
of my previous release, &lt;em&gt;Mastering PostgreSQL in Application Development&lt;/em&gt;.
It contains mostly fixes to the old content, a new title, and a new book
design (PDF and paperback). Content wise, &lt;a href="https://theartofpostgresql.com"&gt;The Art of
PostgreSQL&lt;/a&gt; also comes with a new whole
chapter about PostgreSQL Extensions.&lt;/p&gt;
&lt;p&gt;The new chapter covers extensions such as &lt;code&gt;hstore&lt;/code&gt;, &lt;code&gt;pg_trgm&lt;/code&gt;, &lt;code&gt;intarray&lt;/code&gt;,
&lt;code&gt;earthdistance&lt;/code&gt;, &lt;code&gt;ip4r&lt;/code&gt;, and &lt;code&gt;hll&lt;/code&gt; or HyperLogLog, one of the all times
favorite extensions of &lt;a href="http://www.craigkerstiens.com"&gt;Craig Kerstiens&lt;/a&gt;… who
made himself available to answer my questions and share his view of
PostgreSQL Extensions in an interview!&lt;/p&gt;</description></item><item><title>Preventing SQL Injections</title><link>https://tapoueh.org/blog/2018/11/preventing-sql-injections/</link><pubDate>Sat, 10 Nov 2018 15:40:01 +0100</pubDate><guid>https://tapoueh.org/blog/2018/11/preventing-sql-injections/</guid><description>&lt;p&gt;An &lt;em&gt;SQL Injection&lt;/em&gt; is a security breach, one made famous by the &lt;a href="https://xkcd.com/327/"&gt;Exploits of
a Mom&lt;/a&gt; &lt;code&gt;xkcd&lt;/code&gt; comic episode in which we read about
&lt;em&gt;little Bobby Tables&lt;/em&gt;:&lt;/p&gt;
&lt;figure class="center"&gt;&lt;a href="https://xkcd.com/327/"&gt;&lt;img src="https://tapoueh.org/img/exploits_of_a_mom.png"&gt;&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;PostgreSQL implements a protocol level facility to send the static SQL query
text separately from its dynamic arguments. An SQL injection happens when
the database server is mistakenly led to consider a dynamic argument of a
query as part of the query text. Sending those parts as separate entities
over the protocol means that SQL injection is no longer possible.&lt;/p&gt;
&lt;!--toc--&gt;</description></item><item><title>Geolocation with PostgreSQL</title><link>https://tapoueh.org/blog/2018/08/geolocation-with-postgresql/</link><pubDate>Fri, 24 Aug 2018 12:11:33 +0200</pubDate><guid>https://tapoueh.org/blog/2018/08/geolocation-with-postgresql/</guid><description>&lt;p&gt;We have loaded Open Street Map points of interests in the article &lt;a href="https://tapoueh.org/blog/2013/08/the-most-popular-pub-names/"&gt;The Most
Popular Pub Names&lt;/a&gt; — which
compares PostgreSQL with MongoDB for simple geographical queries, and is
part of our &lt;a href="https://tapoueh.org/tags/extensions/"&gt;PostgreSQL Extensions&lt;/a&gt; article series. In
today&amp;rsquo;s article, look at how to geolocalize an IP address and locate the
nearest pub, all within a single SQL query!&lt;/p&gt;
&lt;p&gt;For that, we are going to use the awesome
&lt;a href="https://github.com/RhodiumToad/ip4r"&gt;ip4r&lt;/a&gt; extension from
&lt;a href="http://blog.rhodiumtoad.org.uk/"&gt;RhodiumToad&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL Concurrency: an Article Series</title><link>https://tapoueh.org/blog/2018/08/postgresql-concurrency-an-article-series/</link><pubDate>Tue, 14 Aug 2018 11:49:02 +0300</pubDate><guid>https://tapoueh.org/blog/2018/08/postgresql-concurrency-an-article-series/</guid><description>&lt;p&gt;&lt;a href="https://www.postgresql.org"&gt;PostgreSQL&lt;/a&gt; is a relational database management
system. It&amp;rsquo;s even the world&amp;rsquo;s most advanced open source one of them. As
such, as its core, Postgres solves concurrent access to a set of data and
maintains consistency while allowing concurrent operations.&lt;/p&gt;
&lt;p&gt;In the &lt;a href="https://tapoueh.org/tags/concurrency/"&gt;PostgreSQL Concurrency&lt;/a&gt; series of articles here
we did see several aspects of how to handle concurrent use cases of your
application design with PostgreSQL. The main thing to remember is that a
Database Management System first task is to handle concurrency access to the
data for you.&lt;/p&gt;</description></item><item><title>Scheduled Data Processing: How to use cron?</title><link>https://tapoueh.org/blog/2018/08/scheduled-data-processing-how-to-use-cron/</link><pubDate>Wed, 01 Aug 2018 11:24:25 +0200</pubDate><guid>https://tapoueh.org/blog/2018/08/scheduled-data-processing-how-to-use-cron/</guid><description>&lt;p&gt;A previous article in the &lt;a href="https://tapoueh.org/tags/concurrency"&gt;PostgreSQL Concurrency&lt;/a&gt; series
covered how to manage concurrent retweets in an efficient way: in &lt;a href="https://tapoueh.org/blog/2018/07/computing-and-caching/"&gt;Computing
and Caching&lt;/a&gt;, we learnt how to
maintain a cache right in your PostgreSQL database, using MATERIALIZED
VIEWS. We also had a look at how to take care of &lt;a href="https://tapoueh.org/blog/2018/07/batch-updates-and-concurrency/"&gt;Batch Updates and
Concurrency&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;While in the first case we are providing a solution to a technical problem
where we want to solve performance issues while keeping the same semantics,
in the second case we are actually implementing a part of the application&amp;rsquo;s
&lt;a href="https://tapoueh.org/blog/2017/06/sql-and-business-logic/"&gt;Business Logic&lt;/a&gt; as a scheduled job.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article shows a modern technique to handle the scheduling of those
business oriented activities that are not tied to any user activity. When
thinking about it this way, you certainly don&amp;rsquo;t want to implement the
backbone of your business logic in a &lt;em&gt;shell script&lt;/em&gt; that&amp;rsquo;s directly
maintained in the production environment, do you?&lt;/p&gt;</description></item><item><title>Batch Updates and Concurrency</title><link>https://tapoueh.org/blog/2018/07/batch-updates-and-concurrency/</link><pubDate>Mon, 23 Jul 2018 22:45:43 +0200</pubDate><guid>https://tapoueh.org/blog/2018/07/batch-updates-and-concurrency/</guid><description>&lt;p&gt;This article fits in the &lt;a href="https://tapoueh.org/tags/concurrency"&gt;PostgreSQL Concurrency&lt;/a&gt; series,
where we installed a tweeter like application schema and had all the
characters from Shakespeare&amp;rsquo;s &lt;em&gt;A Midsummer Night&amp;rsquo;s Dream&lt;/em&gt; tweet their own
lines in our database in &lt;a href="https://tapoueh.org/blog/2018/06/PostgreSQL-DML.md"&gt;PostgreSQL Concurrency: Data Modification
Language&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A previous article in the series covered how to manage concurrent retweets
in an efficient way: &lt;a href="https://tapoueh.org/blog/2018/07/computing-and-caching/"&gt;Computing and
Caching&lt;/a&gt;, where we learn how to
maintain a cache right in your PostgreSQL database, thanks for materialized
views. We even went as far as maintaining an &lt;em&gt;external&lt;/em&gt; cache in another
application layer using PostgreSQL
&lt;a href="https://www.postgresql.org/docs/current/static/sql-listen.html"&gt;LISTEN&lt;/a&gt; and
&lt;a href="https://www.postgresql.org/docs/current/static/sql-notify.html"&gt;NOTIFY&lt;/a&gt;
features and a Golang application.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article is going to address concurrency in the context of updating
data in a batch. This activity is quite common, as soon as your system is
connected to other systems either internally or with external providers.
While it&amp;rsquo;s pretty easy to ingest new data, and easy enough to update data
from an external source when nothing happens in your database, doing the
operation safely with concurrent activity is more complex. Once more though,
PostgreSQL comes with all the tooling you need to handle that situation.&lt;/p&gt;</description></item><item><title>PostgreSQL LISTEN/NOTIFY</title><link>https://tapoueh.org/blog/2018/07/postgresql-listen/notify/</link><pubDate>Thu, 19 Jul 2018 12:58:21 +0200</pubDate><guid>https://tapoueh.org/blog/2018/07/postgresql-listen/notify/</guid><description>&lt;p&gt;This article fits in the &lt;a href="https://tapoueh.org/tags/concurrency"&gt;PostgreSQL Concurrency&lt;/a&gt; series,
where we installed a tweeter like application schema and had all the
characters from Shakespeare&amp;rsquo;s &lt;em&gt;A Midsummer Night&amp;rsquo;s Dream&lt;/em&gt; tweet their own
lines in our database in &lt;a href="https://tapoueh.org/blog/2018/06/PostgreSQL-DML.md"&gt;PostgreSQL Concurrency: Data Modification
Language&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A previous article in the series covered how to manage concurrent retweets
in an efficient way: &lt;a href="https://tapoueh.org/blog/2018/07/computing-and-caching/"&gt;Computing and
Caching&lt;/a&gt;, where we learn how to
maintain a cache right in your PostgreSQL database, thanks for materialized
views.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article shows how to maintain an &lt;em&gt;external&lt;/em&gt; cache in another
application layer. In this article we are going to maintain an in-memory
cache in a Golang service, using PostgreSQL
&lt;a href="https://www.postgresql.org/docs/current/static/sql-listen.html"&gt;LISTEN&lt;/a&gt; and
&lt;a href="https://www.postgresql.org/docs/current/static/sql-notify.html"&gt;NOTIFY&lt;/a&gt;
features.&lt;/p&gt;</description></item><item><title>PostgreSQL Event Based Processing</title><link>https://tapoueh.org/blog/2018/07/postgresql-event-based-processing/</link><pubDate>Mon, 16 Jul 2018 09:27:54 +0200</pubDate><guid>https://tapoueh.org/blog/2018/07/postgresql-event-based-processing/</guid><description>&lt;p&gt;In the previous article of the series &lt;a href="https://tapoueh.org/blog/2018/07/modeling-for-concurrency/"&gt;Modeling for
Concurrency&lt;/a&gt;, we saw how to model
your application for highly concurrent activity. It was a follow-up to the
article entitled &lt;a href="https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/"&gt;PostgreSQL Concurrency: Isolation and
Locking&lt;/a&gt;, which
was a primer on PostgreSQL isolation and locking properties and behaviors.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article takes us a step further and builds on what we did in the
previous articles in our series. After having had all the characters from
Shakespeare&amp;rsquo;s &lt;em&gt;A Midsummer Night&amp;rsquo;s Dream&lt;/em&gt; tweet their own lines in our
database in &lt;a href="https://tapoueh.org/blog/2018/06/PostgreSQL-DML.md"&gt;PostgreSQL Concurrency: Data Modification
Language&lt;/a&gt;, and having had them like and
retweet a lot in &lt;a href="https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/"&gt;PostgreSQL Concurrency: Isolation and
Locking&lt;/a&gt;, we
saw how to manage concurrent retweets in an efficient way in &lt;a href="https://tapoueh.org/blog/2018/07/computing-and-caching/"&gt;Computing and
Caching&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What we did implement in the previous article is a &lt;em&gt;cache&lt;/em&gt; system, all with
its necessary &lt;strong&gt;cache invalidation policy&lt;/strong&gt;. Sometimes though, the
processing of an &lt;em&gt;event&lt;/em&gt; needs to happen within the same transaction where
the event is registered in your system. PostgreSQL makes it possible to
maintain a summary table transactionally thanks to its
&lt;a href="https://www.postgresql.org/docs/current/static/sql-createtrigger.html"&gt;trigger&lt;/a&gt;
support. Today, we&amp;rsquo;re going to dive in how to maintain a summary table with
triggers, and its impact on concurrency.&lt;/p&gt;</description></item><item><title>Computing and Caching</title><link>https://tapoueh.org/blog/2018/07/computing-and-caching/</link><pubDate>Fri, 13 Jul 2018 13:10:21 +0200</pubDate><guid>https://tapoueh.org/blog/2018/07/computing-and-caching/</guid><description>&lt;p&gt;Let&amp;rsquo;s continue to dive in PostgreSQL Concurrency. In the previous article of
the series, &lt;a href="https://tapoueh.org/blog/2018/07/modeling-for-concurrency/"&gt;Modeling for
Concurrency&lt;/a&gt;, we saw how to model
your application for highly concurrent activity. It was a follow-up to the
article entitled &lt;a href="https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/"&gt;PostgreSQL Concurrency: Isolation and
Locking&lt;/a&gt;, which
was a primer on PostgreSQL isolation and locking properties and behaviors.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article takes us a step further and builds on what we did in the
previous articles in our series. After having had all the characters from
Shakespeare&amp;rsquo;s &lt;em&gt;A Midsummer Night&amp;rsquo;s Dream&lt;/em&gt; tweet their own lines in our
database in &lt;a href="https://tapoueh.org/blog/2018/06/PostgreSQL-DML.md"&gt;PostgreSQL Concurrency: Data Modification
Language&lt;/a&gt;, and having had them like a
retweet a lot in &lt;a href="https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/"&gt;PostgreSQL Concurrency: Isolation and
Locking&lt;/a&gt;, it&amp;rsquo;s
time to think about how to display our counters in an efficient way.&lt;/p&gt;
&lt;p&gt;In this article, we&amp;rsquo;re going to think about when we should compute results
and when we should cache them for instant retrieval, all within the SQL
tooling. The SQL tooling for handling cache is a &lt;a href="https://www.postgresql.org/docs/current/static/sql-creatematerializedview.html"&gt;MATERIALIZED
VIEW&lt;/a&gt;,
and it comes with &lt;strong&gt;cache invalidation&lt;/strong&gt; routines, of course.&lt;/p&gt;</description></item><item><title>Modeling for Concurrency</title><link>https://tapoueh.org/blog/2018/07/modeling-for-concurrency/</link><pubDate>Tue, 10 Jul 2018 10:26:47 +0200</pubDate><guid>https://tapoueh.org/blog/2018/07/modeling-for-concurrency/</guid><description>&lt;p&gt;Let&amp;rsquo;s continue to dive in PostgreSQL Concurrency. Last week&amp;rsquo;s article
&lt;a href="https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/"&gt;PostgreSQL Concurrency: Isolation and
Locking&lt;/a&gt; was a
primer on PostgreSQL isolation and locking properties and behaviors.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s article takes us a step further and builds on what we did last week,
in particular the database modeling for a &lt;em&gt;tweet&lt;/em&gt; like application. After
having had all the characters from Shakespeare&amp;rsquo;s &lt;em&gt;A Midsummer Night&amp;rsquo;s Dream&lt;/em&gt;
tweet their own lines in our database in &lt;a href="https://tapoueh.org/blog/2018/06/PostgreSQL-DML.md"&gt;PostgreSQL Concurrency: Data
Modification Language&lt;/a&gt;, it&amp;rsquo;s time for them
to do some actions on the tweets: likes and retweet.&lt;/p&gt;
&lt;p&gt;Of course, we&amp;rsquo;re going to put concurrency to the test, so we&amp;rsquo;re going to
have to handle very very popular tweets from the play!&lt;/p&gt;</description></item><item><title>PostgreSQL Concurrency: Isolation and Locking</title><link>https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/</link><pubDate>Tue, 03 Jul 2018 13:30:13 +0200</pubDate><guid>https://tapoueh.org/blog/2018/07/postgresql-concurrency-isolation-and-locking/</guid><description>&lt;p&gt;&lt;a href="https://www.postgresql.org"&gt;PostgreSQL&lt;/a&gt; is a relational database management
system. It&amp;rsquo;s even the world&amp;rsquo;s most advanced open source one of them. As
such, as its core, Postgres solves concurrent access to a set of data and
maintains consistency while allowing concurrent operations.&lt;/p&gt;
&lt;p&gt;This article is a primer on PostgreSQL Isolation and Locking properties and
behaviors. You might be interested into the previous article in the series:
&lt;a href="https://tapoueh.org/blog/2018/06/postgresql-concurrency-data-modification-language/"&gt;PostgreSQL Concurrency: Data Modification
Language&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL Concurrency: Data Modification Language</title><link>https://tapoueh.org/blog/2018/06/postgresql-concurrency-data-modification-language/</link><pubDate>Mon, 25 Jun 2018 09:58:53 +0200</pubDate><guid>https://tapoueh.org/blog/2018/06/postgresql-concurrency-data-modification-language/</guid><description>&lt;p&gt;&lt;a href="https://www.postgresql.org"&gt;PostgreSQL&lt;/a&gt; is a relational database management
system. It&amp;rsquo;s even the world&amp;rsquo;s most advanced open source one of them. As
such, as its core, Postgres solves concurrent access to a set of data and
maintains consistency while allowing concurrent operations.&lt;/p&gt;
&lt;p&gt;Postgres exposes its concurrency APIs in the SQL language, in particular in
the &lt;a href="https://en.wikipedia.org/wiki/Data_manipulation_language"&gt;DML&lt;/a&gt; parts of
it: you can read the &lt;a href="https://www.postgresql.org/docs/current/static/dml.html"&gt;Data Manipulation
Language&lt;/a&gt; chapter
of the PostgreSQL docs for all the details.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types</title><link>https://tapoueh.org/blog/2018/05/postgresql-data-types/</link><pubDate>Thu, 24 May 2018 14:47:05 +0200</pubDate><guid>https://tapoueh.org/blog/2018/05/postgresql-data-types/</guid><description>&lt;p&gt;Today it&amp;rsquo;s time to conclude our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data
Types&lt;/a&gt; articles with a recap. The series cover lots of
core PostgreSQL data types and shows how to benefit from the PostgreSQL
concept of a data type: more than input validation, a PostgreSQL data type
also implements expected behaviors and processing functions.&lt;/p&gt;
&lt;p&gt;This allows an application developer to rely on PostgreSQL for more complex
queries, having the processing happen where the data is, for instance when
implementing advanced JOIN operations, then retrieving only the data set
that is interesting for the application.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Point</title><link>https://tapoueh.org/blog/2018/05/postgresql-data-types-point/</link><pubDate>Mon, 07 May 2018 10:46:17 +0200</pubDate><guid>https://tapoueh.org/blog/2018/05/postgresql-data-types-point/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL Point type.&lt;/p&gt;
&lt;p&gt;In order to put the Point datatype in a context where it makes sense, we&amp;rsquo;re
going to download a complete geolocation data set and normalize it, thus
making good use of both the normalization good practice and those other
PostgreSQL data types we&amp;rsquo;ve been learning about in the previous articles of
this series.&lt;/p&gt;
&lt;p&gt;Buckle-up, this is a long article with a lot of SQL inside.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: ENUM</title><link>https://tapoueh.org/blog/2018/05/postgresql-data-types-enum/</link><pubDate>Wed, 02 May 2018 11:00:26 +0200</pubDate><guid>https://tapoueh.org/blog/2018/05/postgresql-data-types-enum/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL ENUM type.&lt;/p&gt;
&lt;p&gt;This data type has been added to PostgreSQL in order to make it easier to
support migrations from MySQL. Proper relational design would use a
reference table and a foreign key instead.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: JSON</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-json/</link><pubDate>Mon, 30 Apr 2018 09:49:33 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-json/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL JSON type.&lt;/p&gt;
&lt;p&gt;PostgreSQL has built-in support for JSON with a great range of processing
functions and operators, and complete indexing support. The documentation
covers all the details in the chapters entitled &lt;a href="https://www.postgresql.org/docs/current/static/datatype-json.html"&gt;JSON
Types&lt;/a&gt;
and &lt;a href="https://www.postgresql.org/docs/current/static/functions-json.html"&gt;JSON Functions and
Operators&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: XML</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-xml/</link><pubDate>Mon, 23 Apr 2018 18:18:48 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-xml/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL XML type.&lt;/p&gt;
&lt;p&gt;The SQL standard includes a &lt;a href="https://en.wikipedia.org/wiki/SQL/XML"&gt;SQL/XML&lt;/a&gt;
which &lt;em&gt;introduces the predefined data type XML together with constructors,
several routines, functions, and XML-to-SQL data type mappings to support
manipulation and storage of XML in a SQL database&lt;/em&gt;, as per the Wikipedia
page.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Arrays</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-arrays/</link><pubDate>Fri, 20 Apr 2018 14:47:25 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-arrays/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL array data types.&lt;/p&gt;
&lt;p&gt;Arrays can be used to denormalize data and avoid lookup tables. A good rule
of thumb for using them that way is that you mostly use the array as a
whole, even if you might at times search for elements in the array. Heavier
processing is going to be more complex than a lookup table.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Ranges</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-ranges/</link><pubDate>Wed, 18 Apr 2018 13:41:12 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-ranges/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL ranges data type.&lt;/p&gt;
&lt;p&gt;Range types are a unique feature of PostgreSQL, managing two dimensions of
data in a single column, and allowing advanced processing. The main example
is the &lt;em&gt;daterange&lt;/em&gt; data type, which stores as a single value a lower and an
upper bound of the range as a single value. This allows PostgreSQL to
implement a concurrent safe check against &lt;em&gt;overlapping&lt;/em&gt; ranges, as we&amp;rsquo;re
going to see in this article.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Network Addresses</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-network-addresses/</link><pubDate>Mon, 16 Apr 2018 12:32:53 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-network-addresses/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce network address types.&lt;/p&gt;
&lt;p&gt;PostgreSQL includes support for both &lt;em&gt;cidr&lt;/em&gt;, &lt;em&gt;inet&lt;/em&gt;, and &lt;em&gt;macaddr&lt;/em&gt; data
types. Again, those types are bundled with indexing support and advanced
functions and operator support.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Date and Time Processing</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-date-and-time-processing/</link><pubDate>Fri, 13 Apr 2018 13:35:47 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-date-and-time-processing/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce date and time based processing functions.&lt;/p&gt;
&lt;p&gt;Once the application&amp;rsquo;s data, or rather the user data is properly stored as
timestamp with time zone, PostgreSQL allows implementing all the processing
you need to. In this article we dive into a set of examples to help you get
started with time based processing in your database. Can we boost your
reporting skills?&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Text Processing</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-text-processing/</link><pubDate>Wed, 11 Apr 2018 23:15:42 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-text-processing/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce some of the PostgreSQL text processing functions.&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s a very rich set of PostgreSQL functions to process text — you can
find them all in the &lt;a href="https://www.postgresql.org/docs/current/static/functions-string.html"&gt;string functions and
operators&lt;/a&gt;
documentation chapter — with functions such as &lt;em&gt;overlay()&lt;/em&gt;, &lt;em&gt;substring()&lt;/em&gt;,
&lt;em&gt;position()&lt;/em&gt; or &lt;em&gt;trim()&lt;/em&gt;. Or aggregates such as &lt;em&gt;string_agg()&lt;/em&gt;. There are
also &lt;em&gt;regular expression&lt;/em&gt; functions, including the very powerful
&lt;em&gt;regexp_split_to_table()&lt;/em&gt;. In this article we see practical example putting
them in practice.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: Text Encoding</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-text-encoding/</link><pubDate>Mon, 09 Apr 2018 13:33:01 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-text-encoding/</guid><description>&lt;p&gt;Continuing our series of &lt;a href="https://tapoueh.org/tags/data-types/"&gt;PostgreSQL Data Types&lt;/a&gt; today
we&amp;rsquo;re going to introduce the PostgreSQL text data type. The first notion to
understand when processing text in any program is of course the notion of
encoding.&lt;/p&gt;
&lt;p&gt;So when addressing the text datatype we must mention encoding settings, and
possibly also issues. An encoding is a particular representation of
characters in bits and bytes. In the ASCII encoding the letter &lt;code&gt;A&lt;/code&gt; is
encoded as the 7-bits byte &lt;code&gt;1000001&lt;/code&gt;, or 65 in decimal, or 41 in
hexadecimal. All those numbers are going to be written the same way on-disk,
and the letter &lt;code&gt;A&lt;/code&gt; too.&lt;/p&gt;</description></item><item><title>PostgreSQL Data Types: an intro</title><link>https://tapoueh.org/blog/2018/04/postgresql-data-types-an-intro/</link><pubDate>Fri, 06 Apr 2018 11:32:43 +0200</pubDate><guid>https://tapoueh.org/blog/2018/04/postgresql-data-types-an-intro/</guid><description>&lt;p&gt;Today, we&amp;rsquo;re going to begin a dive into the PostgreSQL Data Types. As my
colleague &lt;a href="https://bitfission.com"&gt;Will Leinweber&lt;/a&gt; said recently in his talk
&lt;a href="https://www.postgresql.eu/events/pgdayparis2018/schedule/session/1835-constraints-a-developers-secret-weapon/"&gt;Constraints: a Developer&amp;rsquo;s Secret
Weapon&lt;/a&gt;
that he gave at &lt;a href="https://2018.pgday.paris"&gt;pgDay Paris&lt;/a&gt;: &lt;a href="https://www.citusdata.com/blog/2018/03/19/postgres-database-constraints/"&gt;database
constraints in Postgres are the last line of
defense&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The most important of those constraints is the data type, or the &lt;em&gt;attribute
domain&lt;/em&gt; in normalization slang. By declaring an attribute to be of a certain
data type, then PostgreSQL ensures that this property is always true, and
then implements advanced processing features for each data type, so that you
may push the computation to the data, when needed.&lt;/p&gt;
&lt;p&gt;This article is the first of a series that will go through many of the
PostgreSQL data types, and we open the journey with &lt;code&gt;boolean&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Object Relational Database Management System</title><link>https://tapoueh.org/blog/2018/03/object-relational-database-management-system/</link><pubDate>Thu, 22 Mar 2018 17:40:39 +0100</pubDate><guid>https://tapoueh.org/blog/2018/03/object-relational-database-management-system/</guid><description>&lt;p&gt;&lt;a href="https://www.postgresql.org"&gt;PostgreSQL&lt;/a&gt; is the world&amp;rsquo;s most advanced open
source database, and per the &lt;a href="https://en.wikipedia.org/wiki/PostgreSQL"&gt;PostgreSQL Wikipedia
page&lt;/a&gt; it is &lt;em&gt;an
&lt;strong&gt;object-relational&lt;/strong&gt; database management system (ORDBMS) with an emphasis
on extensibility and standards compliance&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;In this article, we try to understand why would PostgreSQL be named an
&lt;em&gt;object-relational&lt;/em&gt; thing. What is Object Oriented Programming and how does
that apply to a database system?&lt;/p&gt;</description></item><item><title>Database Normalization and Primary Keys</title><link>https://tapoueh.org/blog/2018/03/database-normalization-and-primary-keys/</link><pubDate>Fri, 09 Mar 2018 18:41:33 +0100</pubDate><guid>https://tapoueh.org/blog/2018/03/database-normalization-and-primary-keys/</guid><description>&lt;p&gt;In our previous article we saw three classic &lt;a href="https://tapoueh.org/blog/2018/03/database-modelization-anti-patterns/"&gt;Database Modelization
Anti-Patterns&lt;/a&gt;. The
article also contains a reference to a Primary Key section of my book &lt;a href="https://theartofpostgresql.com"&gt;The
Art of PostgresQL&lt;/a&gt;, so it&amp;rsquo;s only fair that I
would now publish said Primary Key section!&lt;/p&gt;
&lt;p&gt;So in this article, we dive into Primary Keys as being a cornerstone of
database normalization. It&amp;rsquo;s so important to get Primary Keys right that you
would think everybody knows how to do it, and yet, most of the primary key
constraints I&amp;rsquo;ve seen used in database design are actually not primary keys
at all.&lt;/p&gt;</description></item><item><title>Database Modelization Anti-Patterns</title><link>https://tapoueh.org/blog/2018/03/database-modelization-anti-patterns/</link><pubDate>Thu, 08 Mar 2018 18:00:43 +0100</pubDate><guid>https://tapoueh.org/blog/2018/03/database-modelization-anti-patterns/</guid><description>&lt;p&gt;Next week we see two awesome PostgreSQL conferences in Europe, back to back,
with a day in between just so that people may attend both! In chronological
order we have first &lt;a href="https://2018.nordicpgday.org"&gt;Nordic pgDay&lt;/a&gt; in Oslo
where I will have the pleasure to talk about &lt;a href="https://www.postgresql.eu/events/nordicpgday2018/schedule/session/1896-data-modeling-normalization-and-denormalization/"&gt;Data Modeling, Normalization
and
Denormalization&lt;/a&gt;.
Then we have &lt;a href="https://2018.pgday.paris"&gt;pgday.paris&lt;/a&gt; with an awesome
schedule and a strong focus on the needs of application developers!&lt;/p&gt;</description></item><item><title>Sustainable Open Source Development</title><link>https://tapoueh.org/blog/2018/02/sustainable-open-source-development/</link><pubDate>Tue, 20 Feb 2018 21:08:38 +0100</pubDate><guid>https://tapoueh.org/blog/2018/02/sustainable-open-source-development/</guid><description>&lt;p&gt;Current trend in software deployments is to rely on open source software for
entire production stacks. You can find open source software in the core
technical stacks of every startup out there, I&amp;rsquo;m told. If you&amp;rsquo;re using Cloud
based offerings, most of Cloud providers are running &lt;a href="https://www.gnu.org/philosophy/floss-and-foss.en.html"&gt;Free/Libre Open Source
Software&lt;/a&gt; as their
foundation.&lt;/p&gt;
&lt;p&gt;This article is a deep dive into the economic models behind successful open
source projects and communities, and how as a professional, enterprise grade
user, you depend on the long-term sustainability of all the open source
projects you&amp;rsquo;re using. And because you depend on the projects you&amp;rsquo;re using
to be successful, how to contribute and guarantee their success.&lt;/p&gt;</description></item><item><title>Find the number of the longest continuously rising days for a stock</title><link>https://tapoueh.org/blog/2018/02/find-the-number-of-the-longest-continuously-rising-days-for-a-stock/</link><pubDate>Tue, 06 Feb 2018 23:24:17 +0100</pubDate><guid>https://tapoueh.org/blog/2018/02/find-the-number-of-the-longest-continuously-rising-days-for-a-stock/</guid><description>&lt;p&gt;Today I want to react to an article that claims that &lt;a href="https://www.datasciencecentral.com/profiles/blogs/relational-algebra-is-the-root-of-sql-problems"&gt;Relational Algebra Is
the Root of SQL
Problems&lt;/a&gt;
in which the author hand-waves the following position:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SQL becomes more a hindrance to data manipulation than an efficient tool.
SQL’s greatest problem isn’t in the implementation level, but at its
theory foundation. The problem can’t be solved by application
optimization. Relational algebra isn’t sophisticated enough for handling
the complicated data manipulation scenarios.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then they go on to several &lt;em&gt;arguments from authority&lt;/em&gt; to “prove” their
point. My reading of the article is that SQL is very hard when you didn&amp;rsquo;t
care to learn it, as most technologies are.&lt;/p&gt;
&lt;p&gt;In this article, we&amp;rsquo;re going to look at the &lt;em&gt;simple examples&lt;/em&gt; provided where
apparently SQL makes it so much harder to find a solution compared to
writing some Java or C++ code. Contrary to the original article, we go as
far as to actually writing both the SQL solution and a complete Python
solution, so that we can compare.&lt;/p&gt;</description></item><item><title>Exporting a Hierarchy in JSON: with recursive queries</title><link>https://tapoueh.org/blog/2018/01/exporting-a-hierarchy-in-json-with-recursive-queries/</link><pubDate>Wed, 31 Jan 2018 18:00:01 +0100</pubDate><guid>https://tapoueh.org/blog/2018/01/exporting-a-hierarchy-in-json-with-recursive-queries/</guid><description>&lt;p&gt;In another article here, entitled &lt;a href="https://tapoueh.org/blog/2017/09/on-json-and-sql/"&gt;on JSON and
SQL&lt;/a&gt;, we saw in great details how to import
a data set only available as a giant JSON file. Then we normalized the data
set, so as to be able to write SQL and process our data. This approach is
sometimes very useful and was a good way to learn some of the JSON functions
provided by PostgreSQL.&lt;/p&gt;
&lt;p&gt;In this article, we&amp;rsquo;re going to use SQL to export the data from our
relational model into a JSON document. The trick that makes it complex in
this example is that we have a recursive data model, with a notion of a
&lt;em&gt;parent&lt;/em&gt; row that exists in the same table as the current one. That&amp;rsquo;s a nice
excuse to learn more about the SQL construct &lt;a href="https://www.postgresql.org/docs/current/static/queries-with.html"&gt;WITH
RECURSIVE&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>A Year in Review: Most Read Articles in 2017</title><link>https://tapoueh.org/blog/2018/01/a-year-in-review-most-read-articles-in-2017/</link><pubDate>Sun, 28 Jan 2018 22:46:43 +0100</pubDate><guid>https://tapoueh.org/blog/2018/01/a-year-in-review-most-read-articles-in-2017/</guid><description>&lt;p&gt;It seems to be usual nowadays to review the previous year, and readers
apparently like Top-N Lists — &lt;em&gt;that&amp;rsquo;s you now, so let&amp;rsquo;s hope that my
understanding works with you too&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Of course 2018 will see its own amount of new and original content added to
this blog, with a continuous focus towards how to make the best out of the
SQL powerful programming language, and its advanced concurrency semantics.&lt;/p&gt;</description></item><item><title>Working at Citus Data</title><link>https://tapoueh.org/blog/2018/01/working-at-citus-data/</link><pubDate>Thu, 18 Jan 2018 12:05:13 +0100</pubDate><guid>https://tapoueh.org/blog/2018/01/working-at-citus-data/</guid><description>&lt;p&gt;You might have read it in the news already in Citus&amp;rsquo; blog post by &lt;a href="https://www.citusdata.com/about/team/"&gt;Sumedh
Pathak&lt;/a&gt;: &lt;a href="https://www.citusdata.com/blog/2018/01/12/dimitri-fontaine-postgresql-contributor-joins-citus-data/"&gt;PostgreSQL Expert Dimitri
Fontaine joins Citus
Data&lt;/a&gt;.
I am very happy to join a talented team here at Citus, and excited to work
on an Open Source solution for distributed SQL on-top of PostgreSQL! In this
article I&amp;rsquo;m going to cover my first technical contributions to Citus
database, as it happens that a few patches of mine made it to the main
source tree already.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; It&amp;rsquo;s good to be working on PostgreSQL related source code again,
and to have the opportunity to solve PostgreSQL related problems at scale!&lt;/p&gt;</description></item><item><title>Migrating to PostgreSQL, the White Paper</title><link>https://tapoueh.org/blog/2018/01/migrating-to-postgresql-the-white-paper/</link><pubDate>Thu, 11 Jan 2018 10:01:45 +0100</pubDate><guid>https://tapoueh.org/blog/2018/01/migrating-to-postgresql-the-white-paper/</guid><description>&lt;p&gt;After having been involved in many migration projects over the last 10
years, I decided to publish the following &lt;a href="https://pgloader.io/white-paper"&gt;White
Paper&lt;/a&gt; in order to share my learnings.&lt;/p&gt;
&lt;p&gt;The paper is titled &lt;a href="https://pgloader.io/white-paper"&gt;Migrating to PostgreSQL, Tools and
Methodology&lt;/a&gt; and details the &lt;a href="https://pgloader.io/blog/continuous-migration/"&gt;Continuous
Migration&lt;/a&gt; approach. It
describes how to migrate from another relational database server technology
to PostgreSQL. The reasons to do so are many, and first among them is often
the licensing model.&lt;/p&gt;</description></item><item><title>Submit a Talk to pgDay Paris Today!</title><link>https://tapoueh.org/blog/2017/12/submit-a-talk-to-pgday-paris-today/</link><pubDate>Tue, 26 Dec 2017 16:06:34 +0100</pubDate><guid>https://tapoueh.org/blog/2017/12/submit-a-talk-to-pgday-paris-today/</guid><description>&lt;p&gt;&lt;a href="https://2018.pgday.paris"&gt;pgDay Paris&lt;/a&gt; 4th edition happens March 15, 2018!
And the &lt;a href="https://2018.pgday.paris/callforpapers/"&gt;Call for Papers&lt;/a&gt; is still
open, as it closes with the year: &lt;em&gt;the submission deadline is December 31st,
2017&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;As I&amp;rsquo;ve been organizing the first edition of &lt;em&gt;pgDay Paris&lt;/em&gt; back in 2015,
this very conference is special to me! It&amp;rsquo;s been an amazing experience
launching a new &lt;a href="https://www.postgresql.org"&gt;PostgreSQL&lt;/a&gt; conference…&lt;/p&gt;
&lt;p&gt;Hats off to &lt;a href="https://www.hagander.net"&gt;Magnus&lt;/a&gt; without whom the first
edition would never have happened, and to
&lt;a href="https://twitter.com/pg_xocolatl"&gt;Vik&lt;/a&gt; of course, who took over the
organisation of the conference!&lt;/p&gt;</description></item><item><title>Setting up psql, the PostgreSQL CLI</title><link>https://tapoueh.org/blog/2017/12/setting-up-psql-the-postgresql-cli/</link><pubDate>Fri, 22 Dec 2017 15:23:43 +0100</pubDate><guid>https://tapoueh.org/blog/2017/12/setting-up-psql-the-postgresql-cli/</guid><description>&lt;p&gt;PostgreSQL ships with an interactive console with the command line tool
named &lt;a href="https://www.postgresql.org/docs/current/static/app-psql.html"&gt;psql&lt;/a&gt;.
It can be used both for scripting and interactive usage and is moreover
quite a powerful tool. Interactive features includes &lt;em&gt;autocompletion&lt;/em&gt;,
&lt;em&gt;readline&lt;/em&gt; support (history searches, modern keyboard movements, etc), input
and output redirection, formatted output, and more.&lt;/p&gt;</description></item><item><title>Mastering PostgreSQL: a reader's interview</title><link>https://tapoueh.org/blog/2017/12/mastering-postgresql-a-readers-interview/</link><pubDate>Wed, 13 Dec 2017 17:05:56 +0100</pubDate><guid>https://tapoueh.org/blog/2017/12/mastering-postgresql-a-readers-interview/</guid><description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;Florent Fourcot&lt;/strong&gt;&lt;/em&gt; has read &lt;a href="http://masteringpostgresql.com"&gt;Mastering PostgreSQL in Application
Development&lt;/a&gt; and has seen tremendous
inprovements in his production setup from reading the first chapters and
applying the book advices to his use case.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an interview run with Florent where he explains the context in which
such improvements has been made!&lt;/p&gt;</description></item><item><title>Mastering PostgreSQL: more about the docker image</title><link>https://tapoueh.org/blog/2017/12/mastering-postgresql-more-about-the-docker-image/</link><pubDate>Tue, 12 Dec 2017 23:27:55 +0100</pubDate><guid>https://tapoueh.org/blog/2017/12/mastering-postgresql-more-about-the-docker-image/</guid><description>&lt;p&gt;The Enterprise Edition of &lt;a href="https://masteringpostgresql.com"&gt;Mastering PostgreSQL in Application
Development&lt;/a&gt; ships with a docker image that
hosts both a PostgreSQL server instance with a pre-loaded database, the one
that&amp;rsquo;s used throughout the book examples, and also with a Jupyter Network
notebook that hosts SQL queries thanks to the
&lt;a href="https://github.com/pivotal/sql_magic"&gt;sql_magic&lt;/a&gt; plugin.&lt;/p&gt;</description></item><item><title>Queen, Princesses, and Workers</title><link>https://tapoueh.org/blog/2017/12/queen-princesses-and-workers/</link><pubDate>Mon, 11 Dec 2017 10:19:24 +0100</pubDate><guid>https://tapoueh.org/blog/2017/12/queen-princesses-and-workers/</guid><description>&lt;p&gt;The &lt;a href="https://postgresql.org"&gt;PostgreSQL&lt;/a&gt; community made the explicit choice
some times ago that they would not use the infamous &lt;em&gt;master&lt;/em&gt; and &lt;em&gt;slave&lt;/em&gt;
terminology. Instead, the documentation introduces the concepts of &lt;a href="https://www.postgresql.org/docs/current/static/high-availability.html"&gt;High
Availability, Load Balancing, and
Replication&lt;/a&gt;
with the terms &lt;em&gt;Primary&lt;/em&gt; and &lt;em&gt;Standby&lt;/em&gt;, and the even more generic term
&lt;em&gt;Replica&lt;/em&gt; is used in contexts when only the data flow is considered, rather
than the particular role of a node.&lt;/p&gt;</description></item><item><title>Scaling Python released</title><link>https://tapoueh.org/blog/2017/12/scaling-python-released/</link><pubDate>Tue, 05 Dec 2017 18:10:00 +0100</pubDate><guid>https://tapoueh.org/blog/2017/12/scaling-python-released/</guid><description>&lt;p&gt;Today I am very pleased to announce the release of the book &lt;a href="https://scaling-python.com"&gt;Scaling
Python&lt;/a&gt; from my good friend &lt;a href="https://julien.danjou.info/"&gt;Julien
Danjou&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;As Julien says, &lt;strong&gt;Python applications can handle millions of requests.&lt;/strong&gt;
Well, we know here that it&amp;rsquo;s easier on them when they are using PostgreSQL
of course!&lt;/p&gt;</description></item><item><title>Simple Data Modeling with a Test Data Set</title><link>https://tapoueh.org/blog/2017/11/simple-data-modeling-with-a-test-data-set/</link><pubDate>Mon, 27 Nov 2017 16:23:44 +0100</pubDate><guid>https://tapoueh.org/blog/2017/11/simple-data-modeling-with-a-test-data-set/</guid><description>&lt;p&gt;In &lt;a href="https://tapoueh.org/blog/2017/06/how-to-write-sql/"&gt;How to Write SQL&lt;/a&gt; we saw how to write
SQL queries as separate &lt;code&gt;.sql&lt;/code&gt; files, and we learnt about using query
parameters with the &lt;em&gt;psql&lt;/em&gt; syntax for that (&lt;code&gt;:variable&lt;/code&gt;, &lt;code&gt;:'variable'&lt;/code&gt;, and
&lt;code&gt;:&amp;quot;identifier&amp;quot;&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;For writing our database model, the same tooling is all we need. An
important aspect of using &lt;em&gt;psql&lt;/em&gt; is its capacity to provide immediate
feedback, and we can also have that with modeling too.&lt;/p&gt;</description></item><item><title>The Mode Ordered-Set Aggregate Function</title><link>https://tapoueh.org/blog/2017/11/the-mode-ordered-set-aggregate-function/</link><pubDate>Mon, 13 Nov 2017 18:15:51 +0100</pubDate><guid>https://tapoueh.org/blog/2017/11/the-mode-ordered-set-aggregate-function/</guid><description>&lt;p&gt;In our article &lt;a href="https://tapoueh.org/blog/2017/06/exploring-a-data-set-in-sql/"&gt;Exploring a Data Set in
SQL&lt;/a&gt; we discovered a data set
related to music: the &lt;a href="https://github.com/lerocha/chinook-database"&gt;Chinook&lt;/a&gt;
sample database.&lt;/p&gt;
&lt;p&gt;Our discovery led us to find albums containing tracks of multiple genres,
and for the analytics we were then pursuing, we wanted to &lt;em&gt;clean&lt;/em&gt; the data
set and assign a single genre per album. We did that in SQL of course, and
didn&amp;rsquo;t actually edit the data.&lt;/p&gt;
&lt;p&gt;Finding the most frequent input value in a group is a job for the &lt;code&gt;mode() WITHIN GROUP (ORDER BY sort_expression)&lt;/code&gt; Ordered-Set Aggregate Function, as
documented in the PostgreSQL page about &lt;a href="https://www.postgresql.org/docs/current/static/functions-aggregate.html#FUNCTIONS-ORDEREDSET-TABLE"&gt;Aggregate
Functions&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>What's in a name: “Mastering”</title><link>https://tapoueh.org/blog/2017/11/whats-in-a-name-mastering/</link><pubDate>Thu, 09 Nov 2017 09:34:36 +0100</pubDate><guid>https://tapoueh.org/blog/2017/11/whats-in-a-name-mastering/</guid><description>&lt;p&gt;Now that my book &lt;a href="https://masteringpostgresql.com"&gt;Mastering PostgreSQL in Application
Development&lt;/a&gt; is released (and selling well,
thanks guys!), I&amp;rsquo;ve had some questions about the title.&lt;/p&gt;
&lt;p&gt;The idea is that to become good at anything, we need to practice. We
practice a lot, and it&amp;rsquo;s even better when we are actively trying to learn,
following what&amp;rsquo;s named &lt;a href="https://en.wikipedia.org/wiki/Practice_(learning_method)#Deliberate_practice"&gt;deliberate
practice&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Mastering PostgreSQL in Application Development launches!</title><link>https://tapoueh.org/blog/2017/11/mastering-postgresql-in-application-development-launches/</link><pubDate>Mon, 06 Nov 2017 10:48:43 +0100</pubDate><guid>https://tapoueh.org/blog/2017/11/mastering-postgresql-in-application-development-launches/</guid><description>&lt;p&gt;Today is the day my book &lt;a href="http://masteringpostgresql.com"&gt;Mastering PostgreSQL in Application
Development&lt;/a&gt; launches! I&amp;rsquo;m all excited that
everybody interested is now able to actually read my book!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Mastering PostgreSQL in Application Development&lt;/em&gt; targets application
developers who want to learn SQL properly, and actually master this
programming language. Most developers don&amp;rsquo;t think of SQL as a programming
language, mainly because they don&amp;rsquo;t have full control of the execution plan
of their queries.&lt;/p&gt;
&lt;center&gt;
&lt;figure&gt;&lt;a href="https://masteringpostgresql.com"&gt;&lt;img src="https://tapoueh.org/img/MasteringPostgreSQLinAppDev-Cover-th.png"&gt;&lt;/a&gt;&lt;figcaption&gt;
			&lt;h4&gt;Buy it online!&lt;/h4&gt;
		&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;/center&gt;
&lt;p&gt;When using SQL, you don&amp;rsquo;t get to write how to fetch the data you are
interested in, your job is to &lt;strong&gt;describe&lt;/strong&gt; the data set you need in the
simplest possible way. Sometimes this is pretty easy: I want all the
information we have in the table &lt;em&gt;drivers&lt;/em&gt; about the driver whom &lt;em&gt;driverid&lt;/em&gt;
is &lt;em&gt;1&lt;/em&gt; translates easily to&lt;/p&gt;</description></item><item><title>Set Returning Functions and PostgreSQL 10</title><link>https://tapoueh.org/blog/2017/10/set-returning-functions-and-postgresql-10/</link><pubDate>Fri, 13 Oct 2017 13:25:21 +0200</pubDate><guid>https://tapoueh.org/blog/2017/10/set-returning-functions-and-postgresql-10/</guid><description>&lt;p&gt;PostgreSQL 10 is now available for everyone to use, and hinted by &lt;a href="http://fetter.org"&gt;David
Fetter&lt;/a&gt; I had to review my previous article &lt;a href="https://tapoueh.org/blog/2017/09/on-json-and-sql/"&gt;on Json and
SQL&lt;/a&gt; to adapt to &lt;em&gt;Set Returning Functions&lt;/em&gt;
changes.&lt;/p&gt;
&lt;p&gt;A &lt;em&gt;Set Returning Function&lt;/em&gt; is a PostgreSQL &lt;em&gt;Stored Procedure&lt;/em&gt; that can be
used as a relation: from a single call it returns an entire result set, much
like a subquery or a table.&lt;/p&gt;
&lt;p&gt;It used to be possible to use &lt;em&gt;SRF&lt;/em&gt; in the &lt;em&gt;SELECT&lt;/em&gt; clause, with dubious
(but useful at times) semantics, and also in &lt;em&gt;scalar&lt;/em&gt; contexts. The
semantics have been fixed and are now much clearer, and the uses in scalar
contexts are forbidden — they were a hack and never made sense anyway.&lt;/p&gt;</description></item><item><title>on Json and SQL</title><link>https://tapoueh.org/blog/2017/09/on-json-and-sql/</link><pubDate>Mon, 18 Sep 2017 10:49:03 +0200</pubDate><guid>https://tapoueh.org/blog/2017/09/on-json-and-sql/</guid><description>&lt;p&gt;PostgreSQL has had proper
&lt;a href="https://www.postgresql.org/docs/current/static/datatype-json.html"&gt;json&lt;/a&gt;
support for a while now. The unique extensibility approach of the PostgreSQL
system allows it to enable native &lt;a href="https://www.postgresql.org/docs/current/static/functions-json.html"&gt;SQL friendly JSON
processing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this article we&amp;rsquo;ll play with the &lt;a href="https://mtgjson.com"&gt;Magic: the Gathering card data in JSON
format&lt;/a&gt; data set, provided with a
&lt;a href="https://creativecommons.org/choose/zero/"&gt;CC0&lt;/a&gt; licence, and process the
information provided. We also see how to normalize a JSON document into a
proper database model that benefits from some PostgreSQL advanced features,
and how to then inject the JSON documents into the normalized database
schema. Finally, we compare some non-trivial processing done against both
versions of the database schema.&lt;/p&gt;</description></item><item><title>Mastering PostgreSQL in Application Development</title><link>https://tapoueh.org/blog/2017/09/mastering-postgresql-in-application-development/</link><pubDate>Mon, 11 Sep 2017 15:22:23 +0200</pubDate><guid>https://tapoueh.org/blog/2017/09/mastering-postgresql-in-application-development/</guid><description>&lt;p&gt;&lt;a href="http://masteringpostgresql.com"&gt;Mastering PostgreSQL in Application
Development&lt;/a&gt; is the full title of the book I
am currently writing. Running the &lt;a href="https://tapoueh.org/categories/yesql/"&gt;PostgreSQL is YeSQL&lt;/a&gt;
series of blog posts has shown me developers need a &lt;em&gt;&lt;strong&gt;PostgreSQL book for
developers&lt;/strong&gt;&lt;/em&gt;. A book with the same properties as the &lt;em&gt;YeSQL&lt;/em&gt; series
articles in this blog:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;we use real world data sets to put every query and SQL technique we
learn in the context of a &lt;em&gt;user story&lt;/em&gt; or &lt;em&gt;business case&lt;/em&gt;,&lt;/p&gt;</description></item><item><title>Regular Expressions and Grouping Sets</title><link>https://tapoueh.org/blog/2017/08/regular-expressions-and-grouping-sets/</link><pubDate>Mon, 14 Aug 2017 16:37:53 +0200</pubDate><guid>https://tapoueh.org/blog/2017/08/regular-expressions-and-grouping-sets/</guid><description>&lt;p&gt;There&amp;rsquo;s a very rich set of PostgreSQL functions to process text, you can
find them all at
the
&lt;a href="https://www.postgresql.org/docs/current/static/functions-string.html"&gt;String Functions and Operators&lt;/a&gt; documentation
chapter, with functions such as &lt;em&gt;overlay&lt;/em&gt;, &lt;em&gt;substring&lt;/em&gt;, &lt;em&gt;position&lt;/em&gt; or
&lt;em&gt;trim&lt;/em&gt;. Or aggregates such as &lt;em&gt;string_agg&lt;/em&gt;. And then &lt;em&gt;regular expression&lt;/em&gt;
functions, including the very powerful &lt;em&gt;regexp_split_to_table&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>SQL Regression Tests</title><link>https://tapoueh.org/blog/2017/08/sql-regression-tests/</link><pubDate>Tue, 08 Aug 2017 17:55:51 +0200</pubDate><guid>https://tapoueh.org/blog/2017/08/sql-regression-tests/</guid><description>&lt;p&gt;In a previous article here we
saw &lt;a href="https://tapoueh.org/blog/2017/06/how-to-write-sql/"&gt;How to Write SQL&lt;/a&gt; in your application
code. The main idea in that article is to maintain your queries in separate
SQL files, where it&amp;rsquo;s easier to maintain them. In particular if you want to
be able to test them again in production, and when you have to work and
rewrite queries.&lt;/p&gt;</description></item><item><title>from MySQL to PostgreSQL</title><link>https://tapoueh.org/blog/2017/07/from-mysql-to-postgresql/</link><pubDate>Thu, 06 Jul 2017 17:30:11 +0200</pubDate><guid>https://tapoueh.org/blog/2017/07/from-mysql-to-postgresql/</guid><description>&lt;p&gt;Today
&lt;a href="https://github.com/dimitri/pgloader/releases/tag/v3.4.1"&gt;pgloader v3.4.1&lt;/a&gt;
is released and available! This new release comes with 110 commits as show
in
&lt;a href="https://github.com/dimitri/pgloader/compare/v3.3.2...v3.4.1"&gt;github compare view&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This release of &lt;a href="http://pgloader.io"&gt;pgloader&lt;/a&gt; is following the tradition of
simplifying things for users, or if you allow me to
quote &lt;a href="https://en.wikiquote.org/wiki/Alan_Kay"&gt;Alan Kay&lt;/a&gt;, I believe that if
&lt;em&gt;simple things should be simple, complex things should be possible.&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Playing with Unicode</title><link>https://tapoueh.org/blog/2017/07/playing-with-unicode/</link><pubDate>Mon, 03 Jul 2017 14:32:29 +0200</pubDate><guid>https://tapoueh.org/blog/2017/07/playing-with-unicode/</guid><description>&lt;p&gt;The reason why I like Unicode a lot is because it allows me to code in text
based environments and still have nice output. Today, we&amp;rsquo;re going to play
with
&lt;a href="https://en.wikipedia.org/wiki/Regional_Indicator_Symbol"&gt;Regional Indicator Symbol&lt;/a&gt;,
which is implemented as a Unicode combinaison of letters from 🇦 to 🇿. For
instance, if you display 🇫 then 🇷 concatenated together, you get 🇫🇷. Let&amp;rsquo;s
try that from our &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; prompt!&lt;/p&gt;</description></item><item><title>PostgreSQL and the calendar</title><link>https://tapoueh.org/blog/2017/06/postgresql-and-the-calendar/</link><pubDate>Fri, 30 Jun 2017 14:35:59 +0200</pubDate><guid>https://tapoueh.org/blog/2017/06/postgresql-and-the-calendar/</guid><description>&lt;p&gt;The modern calendar is a trap for the young engineer&amp;rsquo;s mind. We deal with
the calendar on a daily basis and until exposed to its insanity it&amp;rsquo;s rather
common to think that calendar based computations are easy. That&amp;rsquo;s until
you&amp;rsquo;ve tried to do it once. A very good read about how the current calendar
came to be the way it is now is Erik&amp;rsquo;s
Naggum &lt;a href="http://naggum.no/lugm-time.html"&gt;The Long, Painful History of Time&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>SQL and Business Logic</title><link>https://tapoueh.org/blog/2017/06/sql-and-business-logic/</link><pubDate>Mon, 19 Jun 2017 13:30:19 +0200</pubDate><guid>https://tapoueh.org/blog/2017/06/sql-and-business-logic/</guid><description>&lt;p&gt;Business logic is &lt;em&gt;supposed to be&lt;/em&gt; the part of the application where you
deal with customer or user facing decisions and computations. It is often
argued that this part should be well separated from the rest of the
technical infrastructure of your code. Of course, SQL and relational
database design is meant to support your business cases (or user stories),
so then we can ask ourselves if SQL should be part of your business logic
implementation. Or actually, how much of your business logic should be SQL?&lt;/p&gt;</description></item><item><title>Exploring a Data Set in SQL</title><link>https://tapoueh.org/blog/2017/06/exploring-a-data-set-in-sql/</link><pubDate>Tue, 13 Jun 2017 13:47:08 +0200</pubDate><guid>https://tapoueh.org/blog/2017/06/exploring-a-data-set-in-sql/</guid><description>&lt;p&gt;Sometimes you need to dive in an existing data set that you know very little
about. Let&amp;rsquo;s say we&amp;rsquo;ve been lucky to have had a high level description of
the business case covered by a database, and then access to it. Our next
step is figuring out data organisation, content and quality. Our tool box:
&lt;em&gt;the world&amp;rsquo;s most advanced open source
database&lt;/em&gt;, &lt;a href="https://www.postgresql.org"&gt;PostgreSQL&lt;/a&gt;, and its &lt;em&gt;Structured
Query Language&lt;/em&gt;, SQL.&lt;/p&gt;</description></item><item><title>How to Write SQL</title><link>https://tapoueh.org/blog/2017/06/how-to-write-sql/</link><pubDate>Thu, 08 Jun 2017 13:23:26 +0200</pubDate><guid>https://tapoueh.org/blog/2017/06/how-to-write-sql/</guid><description>&lt;p&gt;&lt;a href="https://twitter.com/krisajenkins"&gt;Kris Jenkins&lt;/a&gt; cooked up a very nice way
to embed SQL in your
code: &lt;a href="https://github.com/krisajenkins/yesql"&gt;YeSQL for Clojure&lt;/a&gt;. The main
idea is that you should be writing your SQL queries in &lt;code&gt;.sql&lt;/code&gt; files in your
code repository and maintain them there.&lt;/p&gt;
&lt;p&gt;The idea is very good and it is now possible to find alternative
implementations of the &lt;a href="https://clojure.org"&gt;Clojure&lt;/a&gt; &lt;em&gt;yesql&lt;/em&gt; library in
other languages. Today, we are going to have a look at one of them for
the &lt;a href="https://www.python.org"&gt;python&lt;/a&gt; programming
language: &lt;a href="https://github.com/honza/anosql"&gt;anosql&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Find The Missing Integer</title><link>https://tapoueh.org/blog/2017/05/find-the-missing-integer/</link><pubDate>Tue, 30 May 2017 19:56:54 +0200</pubDate><guid>https://tapoueh.org/blog/2017/05/find-the-missing-integer/</guid><description>&lt;p&gt;A recent interview question that I had to review was spelled like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Find missing int element into array 1..100&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Of course at first read I got it wrong, you have only one integer to look
for into the array. So while the obvious idea was to apply classic &lt;em&gt;sorting&lt;/em&gt;
techniques and minimize array traversal to handle complexity (time and
space), it turns out there&amp;rsquo;s a much simpler way to do it if you remember
your math lessons from younger. But is it that much simpler?&lt;/p&gt;</description></item><item><title>Meetup PostgreSQL à Paris</title><link>https://tapoueh.org/blog/2014/10/meetup-postgresql-%C3%A0-paris/</link><pubDate>Thu, 02 Oct 2014 11:49:00 +0200</pubDate><guid>https://tapoueh.org/blog/2014/10/meetup-postgresql-%C3%A0-paris/</guid><description>&lt;p&gt;Mercredi 8 octobre se tiendra le prochain
&lt;a href="http://www.meetup.com/PostgreSQL-User-Group-Paris/events/209650432/"&gt;Meetup PostgreSQL à Paris&lt;/a&gt; dans les
locaux de
&lt;a href="https://www.mozilla.org/en-US/contact/spaces/paris/"&gt;Mozilla Europe&lt;/a&gt;, dont la capacité est de 90 personnes ! Venez
nombreux !&lt;/p&gt;</description></item><item><title>PostgreSQL, Aggregates and Histograms</title><link>https://tapoueh.org/blog/2014/02/postgresql-aggregates-and-histograms/</link><pubDate>Fri, 21 Feb 2014 13:25:00 +0100</pubDate><guid>https://tapoueh.org/blog/2014/02/postgresql-aggregates-and-histograms/</guid><description>&lt;p&gt;In our previous article
&lt;a href="https://tapoueh.org/blog/2014/02/17-aggregating-nba-data-PostgreSQL-vs-MongoDB"&gt;Aggregating NBA data, PostgreSQL vs MongoDB&lt;/a&gt; we spent
time comparing the pretty new
&lt;em&gt;MongoDB Aggregation Framework&lt;/em&gt; with the decades
old SQL aggregates. Today, let&amp;rsquo;s showcase more of those SQL aggregates,
producing a nice
&lt;em&gt;histogram&lt;/em&gt; right from our SQL console.&lt;/p&gt;</description></item><item><title>Aggregating NBA data, PostgreSQL vs MongoDB</title><link>https://tapoueh.org/blog/2014/02/aggregating-nba-data-postgresql-vs-mongodb/</link><pubDate>Mon, 17 Feb 2014 23:40:00 +0100</pubDate><guid>https://tapoueh.org/blog/2014/02/aggregating-nba-data-postgresql-vs-mongodb/</guid><description>&lt;p&gt;When reading the article
&lt;a href="http://thecodebarbarian.wordpress.com/2014/02/14/crunching-30-years-of-nba-data-with-mongodb-aggregation/"&gt;Crunching 30 Years of NBA Data with MongoDB Aggregation&lt;/a&gt; I coulnd&amp;rsquo;t help but
think that we&amp;rsquo;ve been enjoying
&lt;a href="http://www.postgresql.org/docs/current/static/tutorial-agg.html"&gt;aggregates&lt;/a&gt; in SQL for 3 or 4 decades already.
When using
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; it&amp;rsquo;s even easy to actually add your own aggregates
given the SQL command
&lt;a href="http://www.postgresql.org/docs/current/static/sql-createaggregate.html"&gt;create aggregate&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Denormalizing Tags</title><link>https://tapoueh.org/blog/2013/10/denormalizing-tags/</link><pubDate>Thu, 24 Oct 2013 13:40:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/10/denormalizing-tags/</guid><description>&lt;p&gt;In our
&lt;a href="https://tapoueh.org/tags/extensions"&gt;Tour of Extensions&lt;/a&gt; today&amp;rsquo;s article is about advanced tag indexing. We
have a great data collection to play with and our goal today is to be able
to quickly find data matching a complex set of tags. So, let&amp;rsquo;s find out
those
&lt;a href="http://www.lastfm.fr/"&gt;lastfm&lt;/a&gt; tracks that are tagged as
&lt;em&gt;blues&lt;/em&gt; and
&lt;em&gt;rhythm and blues&lt;/em&gt;, for
instance.&lt;/p&gt;
&lt;!--toc--&gt;
&lt;p&gt;We&amp;rsquo;re going to use
the
&lt;a href="http://labrosa.ee.columbia.edu/millionsong/lastfm"&gt;Last.fm dataset from the Million Song Dataset project&lt;/a&gt; here.
The article where they present their similarity searches is providing the
whole dataset they have as a &lt;a href="http://www.sqlite.org/"&gt;SQLite&lt;/a&gt; database and
they propose to read their python
script
&lt;a href="http://labrosa.ee.columbia.edu/millionsong/sites/default/files/lastfm/demo_tags_db.py"&gt;demo_tags_db.py&lt;/a&gt; to
make sense of it.&lt;/p&gt;</description></item><item><title>An Interview about MariaDB and PostgreSQL</title><link>https://tapoueh.org/blog/2013/10/an-interview-about-mariadb-and-postgresql/</link><pubDate>Wed, 16 Oct 2013 21:07:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/10/an-interview-about-mariadb-and-postgresql/</guid><description>&lt;p&gt;At the
&lt;a href="http://openworldforum.org/en/"&gt;Open World Forum&lt;/a&gt; two weeks ago I had the pleasure to meet with
&lt;a href="http://www.bytebot.net/blog/"&gt;Colin Charles&lt;/a&gt;. We had a nice talk about the current state of both
&lt;a href="https://mariadb.org/"&gt;MariaDB&lt;/a&gt;
and
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;, and even were both interviewed by the Open World Forum Team.
The interview is now available online. Dear French readers, it&amp;rsquo;s in English.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the video:&lt;/p&gt;
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"&gt;
			&lt;iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/I4-ULkWck3Y?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;p&gt;Executive Summary: MariaDB is a drop-in fully Open Source replacement for
MySQL and sees quite some progress and innovation being made, and
&lt;em&gt;&lt;strong&gt;PostgreSQL
is YeSQL!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;</description></item><item><title>PostgreSQL Autonomous Transaction</title><link>https://tapoueh.org/blog/2013/10/postgresql-autonomous-transaction/</link><pubDate>Mon, 14 Oct 2013 11:25:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/10/postgresql-autonomous-transaction/</guid><description>&lt;p&gt;&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; is an all round impressive
&lt;em&gt;Relational DataBase Management System&lt;/em&gt;
which implements the SQL standard (see the very useful reference page
&lt;a href="http://troels.arvin.dk/db/rdbms/"&gt;Comparison of different SQL implementations&lt;/a&gt; for details). PostgreSQL also
provides with unique solutions in the database market and has been leading
innovation for some years now. Still, there&amp;rsquo;s no support for
&lt;em&gt;&lt;strong&gt;Autonomous
Transactions&lt;/strong&gt;&lt;/em&gt; within the server itself. Let&amp;rsquo;s have a look at how to easily
implement them with
&lt;a href="http://wiki.postgresql.org/wiki/PL/Proxy"&gt;PL/Proxy&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL data recovery</title><link>https://tapoueh.org/blog/2013/09/postgresql-data-recovery/</link><pubDate>Tue, 17 Sep 2013 10:39:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/09/postgresql-data-recovery/</guid><description>&lt;p&gt;The following story is only interesting to read if you like it when bad
things happen, or if you don&amp;rsquo;t have a trustworthy backup policy in place. By
trustworthy I mean that
&lt;em&gt;each backup&lt;/em&gt; you take
&lt;strong&gt;must&lt;/strong&gt; be tested with a test
recovery job. Only tested backups will prove useful when you need them. So
go read our
&lt;a href="http://www.postgresql.org/docs/current/interactive/backup.html"&gt;Backup and Restore&lt;/a&gt; documentation chapter then learn how to setup
&lt;a href="http://www.pgbarman.org/"&gt;Barman&lt;/a&gt; for handling
&lt;em&gt;physical backups&lt;/em&gt; and
&lt;a href="http://www.postgresql.org/docs/current/interactive/continuous-archiving.html"&gt;Point In Time Recovery&lt;/a&gt;. Get back
when you have proper backups, including recovery testing in place. We are
waiting for you. Back? Ok, let&amp;rsquo;s see how bad you can end up without backups,
and how to still recover. With luck.&lt;/p&gt;</description></item><item><title>Using trigrams against typos</title><link>https://tapoueh.org/blog/2013/09/using-trigrams-against-typos/</link><pubDate>Fri, 06 Sep 2013 16:15:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/09/using-trigrams-against-typos/</guid><description>&lt;p&gt;In our ongoing
&lt;a href="https://tapoueh.org/tags/extensions"&gt;Tour of Extensions&lt;/a&gt; we played with
&lt;a href="http://www.postgresql.org/docs/current/static/earthdistance.html"&gt;earth distance&lt;/a&gt; in
&lt;a href="https://tapoueh.org/blog/2013/08/05-earthdistance"&gt;How far is the nearest pub?&lt;/a&gt; then with
&lt;a href="http://www.postgresql.org/docs/current/static/hstore.html"&gt;hstore&lt;/a&gt; in a series about trigger,
first to generalize
&lt;a href="https://tapoueh.org/blog/2013/08/23-parametrized-triggers"&gt;Trigger Parameters&lt;/a&gt; then to enable us to
&lt;a href="https://tapoueh.org/blog/2013/08/27-auditing-changes-with-hstore"&gt;Auditing Changes with Hstore&lt;/a&gt;. Today we are going to work with
&lt;a href="http://www.postgresql.org/docs/current/static/pgtrgm.html"&gt;pg_trgm&lt;/a&gt; which
is the
&lt;em&gt;trigrams&lt;/em&gt; PostgreSQL extension: its usage got seriously enhanced in
recent PostgreSQL releases and it&amp;rsquo;s now a poor&amp;rsquo;s man
&lt;a href="http://www.postgresql.org/docs/current/static/textsearch.html"&gt;Full Text Search&lt;/a&gt;
engine.&lt;/p&gt;</description></item><item><title>Auditing Changes with Hstore</title><link>https://tapoueh.org/blog/2013/08/auditing-changes-with-hstore/</link><pubDate>Tue, 27 Aug 2013 17:35:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/08/auditing-changes-with-hstore/</guid><description>&lt;p&gt;In a previous article about
&lt;a href="https://tapoueh.org/blog/2013/08/23-parametrized-triggers"&gt;Trigger Parameters&lt;/a&gt; we have been using the
extension
&lt;a href="http://www.postgresql.org/docs/9.2/static/hstore.html"&gt;hstore&lt;/a&gt; in order to compute some extra field in our records, where
the fields used both for the computation and for storing the results were
passed in as
&lt;em&gt;dynamic parameters&lt;/em&gt;. Today we&amp;rsquo;re going to see another
&lt;em&gt;trigger&lt;/em&gt;
use case for
&lt;em&gt;hstore&lt;/em&gt;: we are going to record changes made to our tuples.&lt;/p&gt;</description></item><item><title>Trigger Parameters</title><link>https://tapoueh.org/blog/2013/08/trigger-parameters/</link><pubDate>Fri, 23 Aug 2013 12:08:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/08/trigger-parameters/</guid><description>&lt;p&gt;Sometimes you want to compute values automatically at
&lt;code&gt;INSERT&lt;/code&gt; time, like for
example a
&lt;em&gt;duration&lt;/em&gt; column out of a
&lt;em&gt;start&lt;/em&gt; and an
&lt;em&gt;end&lt;/em&gt; column, both
&lt;em&gt;timestamptz&lt;/em&gt;. It&amp;rsquo;s easy enough to do with a
&lt;code&gt;BEFORE TRIGGER&lt;/code&gt; on your table.
What&amp;rsquo;s more complex is to come up with a parametrized spelling of the
trigger, where you can attach the same
&lt;em&gt;stored procedure&lt;/em&gt; to any table even
when the column names are different from one another.&lt;/p&gt;</description></item><item><title>Understanding Window Functions</title><link>https://tapoueh.org/blog/2013/08/understanding-window-functions/</link><pubDate>Tue, 20 Aug 2013 12:04:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/08/understanding-window-functions/</guid><description>&lt;p&gt;There was SQL
before
&lt;a href="http://www.postgresql.org/docs/current/static/tutorial-window.html"&gt;window functions&lt;/a&gt; and
SQL after &lt;em&gt;window functions&lt;/em&gt;: that&amp;rsquo;s how powerful this tool is. Being that
of a deal breaker unfortunately means that it can be quite hard to grasp the
feature. This article aims at making it crystal clear so that you can begin
using it today and are able to reason about it and recognize cases where you
want to be using &lt;em&gt;window functions&lt;/em&gt;.&lt;/p&gt;
&lt;center&gt;
&lt;div class="figure fig50 dim-margin"&gt;
 &lt;a href="https://tapoueh.org/img/old/moving_window.gif"&gt;
 &lt;img class="fig-img" src="https://tapoueh.org/img/old/moving_window.gif" loading="lazy"&gt;
 &lt;/a&gt;&lt;/div&gt;
&lt;/center&gt;
&lt;center&gt;*We see a part of the data as if through a little window*&lt;/center&gt;</description></item><item><title>How far is the nearest pub?</title><link>https://tapoueh.org/blog/2013/08/how-far-is-the-nearest-pub/</link><pubDate>Mon, 05 Aug 2013 08:11:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/08/how-far-is-the-nearest-pub/</guid><description>&lt;p&gt;In our recent article
about &lt;a href="https://tapoueh.org/blog/2013/08/02-pub-names-knn"&gt;The Most Popular Pub Names&lt;/a&gt; we did
have a look at how to find the pubs nearby, but didn&amp;rsquo;t compute the
&lt;strong&gt;distance&lt;/strong&gt; in between that pub and us. That&amp;rsquo;s because how to compute a
distance given a position on the earth expressed as &lt;em&gt;longitude&lt;/em&gt; and
&lt;em&gt;latitude&lt;/em&gt; is not that easy. Today, we are going to solve that problem
nonetheless, thanks
to
&lt;a href="http://www.postgresql.org/docs/9.2/interactive/extend-extensions.html"&gt;PostgreSQL Extensions&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>The Most Popular Pub Names</title><link>https://tapoueh.org/blog/2013/08/the-most-popular-pub-names/</link><pubDate>Fri, 02 Aug 2013 10:19:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/08/the-most-popular-pub-names/</guid><description>&lt;p&gt;In his article
titled
&lt;a href="http://blog.mongodb.org/post/56876800071/the-most-popular-pub-names?utm_content=buffer4922c&amp;amp;utm_source=buffer&amp;amp;utm_medium=facebook&amp;amp;utm_campaign=Buffer"&gt;The Most Popular Pub Names&lt;/a&gt; &lt;em&gt;Ross
Lawley&lt;/em&gt; did show us how to perform some quite interesting &lt;em&gt;geographic
queries&lt;/em&gt; against &lt;a href="http://www.mongodb.org/"&gt;MongoDB&lt;/a&gt;, using some nice &lt;em&gt;Open
Data&lt;/em&gt; found at the &lt;a href="http://www.openstreetmap.org/"&gt;Open Street Map&lt;/a&gt; project.&lt;/p&gt;</description></item><item><title>Archiving data as fast as possible</title><link>https://tapoueh.org/blog/2013/07/archiving-data-as-fast-as-possible/</link><pubDate>Fri, 05 Jul 2013 15:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/07/archiving-data-as-fast-as-possible/</guid><description>&lt;p&gt;In a recent article here we&amp;rsquo;ve been talking about how do do
&lt;a href="https://tapoueh.org/blog/2013/03/15-batch-update"&gt;Batch Updates&lt;/a&gt; in
a very efficient way, using the
&lt;em&gt;Writable CTE&lt;/em&gt; features available in
PostgreSQL 9.1. I sometime read how
&lt;a href="http://www.postgresql.org/docs/current/interactive/queries-with.html"&gt;Common Table Expressions&lt;/a&gt; changed the
life of fellow DBAs and developers, and would say that
&lt;em&gt;Writable CTE&lt;/em&gt; are at
least the same boost again.&lt;/p&gt;</description></item><item><title>Simple Case for Pivoting in SQL</title><link>https://tapoueh.org/blog/2013/07/simple-case-for-pivoting-in-sql/</link><pubDate>Thu, 04 Jul 2013 15:55:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/07/simple-case-for-pivoting-in-sql/</guid><description>&lt;p&gt;In a recent article
&lt;a href="http://www.craigkerstiens.com/"&gt;Craig Kerstiens&lt;/a&gt; from
&lt;a href="https://postgres.heroku.com/"&gt;Heroku&lt;/a&gt; did demo the really useful
&lt;a href="http://www.postgresql.org/docs/current/static/tablefunc.html"&gt;crosstab&lt;/a&gt; extension. That function allows you to
&lt;em&gt;pivot&lt;/em&gt; a table so that you
can see the data from different categories in separate columns in the same
row rather than in separate rows. The article from
&lt;em&gt;&lt;strong&gt;Craig&lt;/strong&gt;&lt;/em&gt; is
&lt;a href="http://www.craigkerstiens.com/2013/06/27/Pivoting-in-Postgres/"&gt;Pivoting in Postgres&lt;/a&gt;.&lt;/p&gt;
&lt;center&gt;*Pivoting a matrix, also known as a matrix transposition*&lt;/center&gt;
&lt;p&gt;Let&amp;rsquo;s do the same setup as he did, with a table containing some randomly
generated data about hypothetical visits to a web page, say, by date then by
operating system.&lt;/p&gt;</description></item><item><title>Nearest Big City</title><link>https://tapoueh.org/blog/2013/05/nearest-big-city/</link><pubDate>Thu, 02 May 2013 11:34:00 +0200</pubDate><guid>https://tapoueh.org/blog/2013/05/nearest-big-city/</guid><description>&lt;p&gt;In this article, we want to find the town with the greatest number of
inhabitants near a given location.&lt;/p&gt;
&lt;!--toc--&gt;
&lt;h2 id="a-very-localized-example"&gt;A very localized example&lt;/h2&gt;
&lt;p&gt;We first need to find and import some data, and I found at the following
place a
&lt;a href="http://www.lion1906.com/Pages/francais/utile/telechargements.html"&gt;CSV listing of french cities with coordinates and population&lt;/a&gt; and
some numbers of interest for the exercise here.&lt;/p&gt;
&lt;p&gt;To import the data set, we first need a table, then a
&lt;code&gt;COPY&lt;/code&gt; command:&lt;/p&gt;</description></item><item><title>Bulk Replication</title><link>https://tapoueh.org/blog/2013/03/bulk-replication/</link><pubDate>Mon, 18 Mar 2013 14:54:00 +0100</pubDate><guid>https://tapoueh.org/blog/2013/03/bulk-replication/</guid><description>&lt;p&gt;In the previous article here we talked about how to
&lt;em&gt;properly&lt;/em&gt; update more
than one row at a time, under the title
&lt;a href="http://tapoueh.org/blog/2013/03/15-batch-update.html"&gt;Batch Update&lt;/a&gt;. We did consider
performances, including network round trips, and did look at the behavior of
our results when used concurrently.&lt;/p&gt;
&lt;p&gt;A case where we want to apply the previous article approach is when
replicating data with a
&lt;em&gt;trigger based solution&lt;/em&gt;, such as
&lt;a href="http://wiki.postgresql.org/wiki/SkyTools"&gt;SkyTools&lt;/a&gt; and
&lt;a href="https://github.com/markokr/skytools"&gt;londiste&lt;/a&gt;. Well, maybe not in all cases, we need to have a amount of
&lt;code&gt;UPDATE&lt;/code&gt;
trafic worthy of setting up the solution. As soon as we know we&amp;rsquo;re getting
to
&lt;em&gt;replay&lt;/em&gt; important enough batches of events, though, certainly using the
&lt;em&gt;batch update&lt;/em&gt; tricks makes sense.&lt;/p&gt;</description></item><item><title>Batch Update</title><link>https://tapoueh.org/blog/2013/03/batch-update/</link><pubDate>Fri, 15 Mar 2013 10:47:00 +0100</pubDate><guid>https://tapoueh.org/blog/2013/03/batch-update/</guid><description>&lt;p&gt;Performance consulting involves some tricks that you have to teach over and
over again. One of them is that SQL tends to be so much better at dealing
with plenty of rows in a single statement when compared to running as many
statements, each one against a single row.&lt;/p&gt;</description></item><item><title>HyperLogLog Unions</title><link>https://tapoueh.org/blog/2013/02/hyperloglog-unions/</link><pubDate>Tue, 26 Feb 2013 12:44:00 +0100</pubDate><guid>https://tapoueh.org/blog/2013/02/hyperloglog-unions/</guid><description>&lt;p&gt;In the article from yesterday we talked about
&lt;a href="http://tapoueh.org/blog/2013/02/25-postgresql-hyperloglog.html"&gt;PostgreSQL HyperLogLog&lt;/a&gt; with
some details. The real magic of that extension has been skimmed over though,
and needs another very small article all by itself, in case you missed it.&lt;/p&gt;
&lt;center&gt;*Which Set Operation do you want for counting unique values?*&lt;/center&gt;
&lt;p&gt;The first query here has the default level of magic in it, really. What
happens is that each time we do an update of the
&lt;em&gt;HyperLogLog&lt;/em&gt;
&lt;em&gt;hash&lt;/em&gt; value, we
update some data which are allowing us to compute its cardinality.&lt;/p&gt;</description></item><item><title>PostgreSQL HyperLogLog</title><link>https://tapoueh.org/blog/2013/02/postgresql-hyperloglog/</link><pubDate>Mon, 25 Feb 2013 10:23:00 +0100</pubDate><guid>https://tapoueh.org/blog/2013/02/postgresql-hyperloglog/</guid><description>&lt;p&gt;If you&amp;rsquo;ve been following along at home the newer statistics developments,
you might have heard about this new
&lt;a href="http://research.google.com/pubs/pub40671.html"&gt;State of The Art Cardinality Estimation Algorithm&lt;/a&gt; called
&lt;a href="http://metamarkets.com/2012/fast-cheap-and-98-right-cardinality-estimation-for-big-data/"&gt;HyperLogLog&lt;/a&gt;. This
technique is now available for PostgreSQL in the extension
&lt;a href="http://blog.aggregateknowledge.com/2013/02/04/open-source-release-postgresql-hll/"&gt;postgresql-hll&lt;/a&gt;
available at
&lt;a href="https://github.com/aggregateknowledge/postgresql-hll"&gt;https://github.com/aggregateknowledge/postgresql-hll&lt;/a&gt; and soon
to be in
&lt;code&gt;debian&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Extensions Templates</title><link>https://tapoueh.org/blog/2013/01/extensions-templates/</link><pubDate>Tue, 08 Jan 2013 17:53:00 +0100</pubDate><guid>https://tapoueh.org/blog/2013/01/extensions-templates/</guid><description>&lt;p&gt;In a recent article titled
&lt;a href="../../2012/12/13-Inline-Extensions.html"&gt;Inline Extensions&lt;/a&gt; we detailed the problem of how
to distribute an extension&amp;rsquo;s
&lt;em&gt;package&lt;/em&gt; to a remote server without having
access to its file system at all. The solution to that problem is non
trivial, let&amp;rsquo;s say. But thanks to the awesome
&lt;a href="http://www.postgresql.org/community/"&gt;PostgreSQL Community&lt;/a&gt; we finaly
have some practical ideas on how to address the problem as discussed on
&lt;a href="http://archives.postgresql.org/pgsql-hackers/"&gt;pgsql-hackers&lt;/a&gt;, our development mailing list.&lt;/p&gt;
&lt;center&gt;*PostgreSQL is first an Awesome Community*&lt;/center&gt;
&lt;p&gt;The solution we talked about is to use
&lt;em&gt;templates&lt;/em&gt;, and so I&amp;rsquo;ve been working
on a patch to bring
&lt;em&gt;templates for extensions&lt;/em&gt; to PostgreSQL. As we&amp;rsquo;re talking
about 3 new system catalogs, that&amp;rsquo;s a big patch in term of lines of code. In
term of features though, it&amp;rsquo;s quite an easy one.&lt;/p&gt;</description></item><item><title>Inline Extensions</title><link>https://tapoueh.org/blog/2012/12/inline-extensions/</link><pubDate>Thu, 13 Dec 2012 11:34:00 +0100</pubDate><guid>https://tapoueh.org/blog/2012/12/inline-extensions/</guid><description>&lt;p&gt;We&amp;rsquo;ve been having the
&lt;code&gt;CREATE EXTENSION&lt;/code&gt; feature in
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; for a couple of
releases now, so let&amp;rsquo;s talk about how to go from here. The first goal of the
extension facility has been to allow for a clean
&lt;em&gt;dump&lt;/em&gt; and
&lt;em&gt;restore&lt;/em&gt; process of
&lt;a href="http://www.postgresql.org/docs/9.2/static/contrib.html"&gt;contrib&lt;/a&gt; modules. As such it&amp;rsquo;s been tailored to the needs of deploying files
on the
&lt;em&gt;file system&lt;/em&gt; because there&amp;rsquo;s no escaping from that when you have to
ship
&lt;em&gt;binary&lt;/em&gt; and
&lt;em&gt;executable&lt;/em&gt; files, those infamous
&lt;code&gt;.so&lt;/code&gt;,
&lt;code&gt;.dll&lt;/code&gt; or
&lt;code&gt;.dylib&lt;/code&gt; things.&lt;/p&gt;</description></item><item><title>Prefixes and Ranges</title><link>https://tapoueh.org/blog/2012/10/prefixes-and-ranges/</link><pubDate>Tue, 16 Oct 2012 10:47:00 +0200</pubDate><guid>https://tapoueh.org/blog/2012/10/prefixes-and-ranges/</guid><description>&lt;p&gt;It&amp;rsquo;s been a long time since I last had some time to spend on the
&lt;a href="http://tapoueh.org/pgsql/prefix.html"&gt;prefix&lt;/a&gt;
PostgreSQL extension and its
&lt;code&gt;prefix_range&lt;/code&gt; data type. With PostgreSQL 9.2
out, some users wanted me to update the extension for that release, and
hinted me that it was high time that I fix that old bug for which I already
had a patch.&lt;/p&gt;
&lt;h2 id="prefix_range-release-120"&gt;&lt;code&gt;prefix_range&lt;/code&gt; release 1.2.0&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;m sorry it took that long. It&amp;rsquo;s now done, you can have
&lt;code&gt;prefix 1.2.0&lt;/code&gt; from
&lt;a href="https://github.com/dimitri/prefix"&gt;https://github.com/dimitri/prefix&lt;/a&gt; or if you want a
&lt;em&gt;tagged&lt;/em&gt; tarball then you
can use this link:
&lt;a href="https://github.com/dimitri/prefix/tarball/v1.2.0"&gt;https://github.com/dimitri/prefix/tarball/v1.2.0&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Reset Counter</title><link>https://tapoueh.org/blog/2012/10/reset-counter/</link><pubDate>Fri, 05 Oct 2012 09:44:00 +0200</pubDate><guid>https://tapoueh.org/blog/2012/10/reset-counter/</guid><description>&lt;p&gt;I&amp;rsquo;ve been given a nice puzzle that I think is a good blog article
opportunity, as it involves some thinking and &lt;a href="https://tapoueh.org/blog/2013/08/understanding-window-functions/"&gt;window
functions&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>PostgreSQL 9.3</title><link>https://tapoueh.org/blog/2012/09/postgresql-9.3/</link><pubDate>Sat, 15 Sep 2012 18:43:00 +0200</pubDate><guid>https://tapoueh.org/blog/2012/09/postgresql-9.3/</guid><description>&lt;p&gt;&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL 9.2&lt;/a&gt; is released! It&amp;rsquo;s an awesome new release that I urge you to
consider trying and adopting, an upgrade from even
&lt;code&gt;9.1&lt;/code&gt; should be very well
worth it, as your hardware could suddenly be able to process a much higher
load. Indeed, better performances mean more work done on the same budget,
that&amp;rsquo;s the name of the game!&lt;/p&gt;
&lt;p&gt;As a
&lt;em&gt;PostgreSQL contributor&lt;/em&gt; though, the release of
&lt;code&gt;9.2&lt;/code&gt; mainly means to me
that it&amp;rsquo;s time to fully concentrate on preparing
&lt;code&gt;9.3&lt;/code&gt;. The developement
&lt;em&gt;season&lt;/em&gt; of which as already begun, by the way, so some amount of work has
already been done here.&lt;/p&gt;</description></item><item><title>Clean PGQ Subconsumers</title><link>https://tapoueh.org/blog/2012/04/clean-pgq-subconsumers/</link><pubDate>Thu, 26 Apr 2012 15:05:00 +0200</pubDate><guid>https://tapoueh.org/blog/2012/04/clean-pgq-subconsumers/</guid><description>&lt;p&gt;Now that you&amp;rsquo;re all using the wonders of
&lt;a href="../03/12-PGQ-Cooperative-Consumers.html"&gt;Cooperative Consumers&lt;/a&gt; to help you
efficiently and reliably implement your business constraints and offload
them from the main user transactions, you&amp;rsquo;re reaching a point where you have
to clean up your development environment (because that&amp;rsquo;s what happens to
development environments, right?), and you want a way to start again from a
clean empty place.&lt;/p&gt;
&lt;p&gt;Here we go. It used to be much more simple than that, so if you&amp;rsquo;re still
using
&lt;strong&gt;PGQ&lt;/strong&gt; from
&lt;strong&gt;Skytools2&lt;/strong&gt;, just jump to the next step.&lt;/p&gt;</description></item><item><title>PGQ Coop Consumers</title><link>https://tapoueh.org/blog/2012/03/pgq-coop-consumers/</link><pubDate>Mon, 12 Mar 2012 14:43:00 +0100</pubDate><guid>https://tapoueh.org/blog/2012/03/pgq-coop-consumers/</guid><description>&lt;p&gt;While working a new
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; architecture for an high scale project that
used to be in the top 10 of internet popular web sites (in terms of
visitors), I needed to be able to off load some processing from the main
path: that&amp;rsquo;s called a
&lt;em&gt;batch job&lt;/em&gt;. This needs to be
&lt;em&gt;transactional&lt;/em&gt;: don&amp;rsquo;t run
the job if we did
&lt;code&gt;rollback;&lt;/code&gt; the transaction, process all
&lt;em&gt;events&lt;/em&gt; that were
part of the same transaction in the same transaction, etc.&lt;/p&gt;</description></item><item><title>Extension White Listing</title><link>https://tapoueh.org/blog/2012/03/extension-white-listing/</link><pubDate>Thu, 08 Mar 2012 14:25:00 +0100</pubDate><guid>https://tapoueh.org/blog/2012/03/extension-white-listing/</guid><description>&lt;p&gt;PostgreSQL 9.1 includes proper extension support, as you might well know if
you ever read this very blog here. Some hosting facilities are playing with
PostgreSQL at big scale (hello
&lt;a href="https://postgres.heroku.com/blog"&gt;Heroku&lt;/a&gt;!) and still meet with small caveats
making their life uneasy.&lt;/p&gt;
&lt;p&gt;To be specific, only
&lt;em&gt;superusers&lt;/em&gt; are allowed to install C coded stored
procedures, and that impacts a lot of very useful PostgreSQL extension: all
those shiped in the
&lt;em&gt;contrib&lt;/em&gt; package are coded in C. Now,
&lt;a href="https://postgres.heroku.com/blog"&gt;Heroku&lt;/a&gt; is not
giving away
&lt;em&gt;superuser&lt;/em&gt; access to their hosted customers in order to limit the
number of ways they can shoot themselves in the foot. And given PostgreSQL
security model, being granted
&lt;em&gt;database owner&lt;/em&gt; is mostly good enough for day
to day operation.&lt;/p&gt;</description></item><item><title>pgbouncer munin plugin</title><link>https://tapoueh.org/blog/2011/11/pgbouncer-munin-plugin/</link><pubDate>Wed, 16 Nov 2011 14:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2011/11/pgbouncer-munin-plugin/</guid><description>&lt;p&gt;It seems that if you search for a
&lt;a href="http://munin-monitoring.org/"&gt;munin&lt;/a&gt; plugin for
&lt;a href="http://wiki.postgresql.org/wiki/PgBouncer"&gt;pgbouncer&lt;/a&gt; it&amp;rsquo;s easy
enough to reach an old page of mine with an old version of my plugin, and a
broken link. Let&amp;rsquo;s remedy that by publishing here the newer version of the
plugin. To be honest, I though it already made its way into the official
munin
&lt;code&gt;1.4&lt;/code&gt; set of plugins, but I&amp;rsquo;ve not been following closely enough.&lt;/p&gt;
&lt;p&gt;As the plugin is 300 lines of python code, it&amp;rsquo;s not a good idea to just
inline it here, so please grab it at
&lt;a href="../../../resources/pgbouncer_"&gt;pgbouncer_&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Extensions en simple SQL</title><link>https://tapoueh.org/blog/2011/10/extensions-en-simple-sql/</link><pubDate>Mon, 31 Oct 2011 14:22:00 +0100</pubDate><guid>https://tapoueh.org/blog/2011/10/extensions-en-simple-sql/</guid><description>&lt;p&gt;La
&lt;a href="http://2011.pgconf.eu/"&gt;conférence européenne à Amsterdam&lt;/a&gt; était un très bon évènement de la
communauté, avec une organisation impeccable dans un hôtel accueillant. J&amp;rsquo;ai
eu le plaisir d&amp;rsquo;y parler des extensions et de leur usage dans le cadre du
développement applicatif « interne », sous le titre
&lt;a href="http://www.postgresql.eu/events/schedule/pgconfeu2011/session/138-extensions-are-good-for-business-logic/"&gt;Extensions are good for business logic&lt;/a&gt;.&lt;/p&gt;
&lt;center&gt;
&lt;div class="figure dim-margin"&gt;
 &lt;a href="http://wiki.postgresql.org/images/f/f1/Using-extensions.pdf"&gt;
 &lt;img src="https://tapoueh.org/img/old/using-extensions-10.png"&gt;
 &lt;/a&gt;
&lt;/div&gt;
&lt;/center&gt;
&lt;p&gt;L&amp;rsquo;idée de ma présentation, que la plupart d&amp;rsquo;entre vous a loupé je suppose
(en tout cas je n&amp;rsquo;avais qu&amp;rsquo;une petite poignée de français dans la salle, et
j&amp;rsquo;espère avoir des lecteurs qui n&amp;rsquo;étaient pas à Amsterdam), l&amp;rsquo;idée est
d&amp;rsquo;utiliser les mécanismes offerts par les extensions afin de maintenir le
code
&lt;code&gt;PL&lt;/code&gt; que vous utilisez en production.&lt;/p&gt;</description></item><item><title>Scaling Stored Procedures</title><link>https://tapoueh.org/blog/2011/10/scaling-stored-procedures/</link><pubDate>Thu, 06 Oct 2011 18:23:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/10/scaling-stored-procedures/</guid><description>&lt;p&gt;In the news recently
&lt;em&gt;stored procedures&lt;/em&gt; where used as an excuse for moving
away logic from the database layer to application layer, and to migrate away
from a powerful technology to a simpler one, now that there&amp;rsquo;s no logic
anymore in the database.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not the way I would typically approach scaling problems, and apparently
I&amp;rsquo;m not alone on the
&lt;em&gt;Stored Procedures&lt;/em&gt; camp. Did you read this nice blog
post
&lt;a href="http://ora-00001.blogspot.com/2011/07/mythbusters-stored-procedures-edition.html"&gt;Mythbusters: Stored Procedures Edition&lt;/a&gt; already? Well it happens in
another land that where my comfort zone is, but still has some interesting
things to say.&lt;/p&gt;</description></item><item><title>Skytools3: walmgr</title><link>https://tapoueh.org/blog/2011/09/skytools3-walmgr/</link><pubDate>Wed, 21 Sep 2011 17:21:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/09/skytools3-walmgr/</guid><description>&lt;p&gt;Let&amp;rsquo;s begin the
&lt;a href="http://wiki.postgresql.org/wiki/SkyTools"&gt;Skytools 3&lt;/a&gt; documentation effort, which is long overdue. The
code is waiting for you over at
&lt;a href="https://github.com/markokr/skytools"&gt;github&lt;/a&gt;, and is stable and working. Why is
it still in
&lt;em&gt;release candidate&lt;/em&gt; status, I hear you asking? Well because it&amp;rsquo;s
missing updated documentation.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://packages.debian.org/experimental/skytools3-walmgr"&gt;WalMgr&lt;/a&gt; is the Skytools component that manages
&lt;em&gt;WAL shipping&lt;/em&gt; for you, and
archiving too. It knows how to prepare your master and standby setup, how
to take a base backup and push it to the standby&amp;rsquo;s system, how to archive
(at the satndby) master&amp;rsquo;s WAL files as they are produced and have the
standby restore from this archive.&lt;/p&gt;</description></item><item><title>PostgreSQL 9.1</title><link>https://tapoueh.org/blog/2011/09/postgresql-9.1/</link><pubDate>Wed, 14 Sep 2011 10:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/09/postgresql-9.1/</guid><description>&lt;p&gt;&lt;a href="http://www.postgresql.org/about/news.1349"&gt;PostgreSQL 9.1&lt;/a&gt; est dans les bacs ! Vous n&amp;rsquo;avez pas encore cette nouvelle
version en production ? Pas encore évalué pourquoi vous devriez envisager
de migrer à cette version ? Il existe beaucoup de bonnes raisons de passer
à cette version, et peu de pièges.&lt;/p&gt;
&lt;p&gt;Nous commençons à lire des articles qui reprennent la nouvelle dans la
presse française, et j&amp;rsquo;ai le plaisir de mentionner celui de
&lt;a href="http://www.programmez.com/actualites.php?titre_actu=Sortie-de-PostgreSQL-91-!&amp;amp;id_actu=10190"&gt;programmez.com&lt;/a&gt;
qui annonce « un système d&amp;rsquo;extensions inégalé ». En tant que développeur
des
&lt;a href="http://www.postgresql.org/docs/9.1/static/extend-extensions.html"&gt;Extensions&lt;/a&gt; dans PostgreSQL, je ne peux qu&amp;rsquo;être non seulement d&amp;rsquo;accord
avec eux, mais aussi flatté :)&lt;/p&gt;</description></item><item><title>Éviter les injections SQL</title><link>https://tapoueh.org/blog/2011/09/%C3%A9viter-les-injections-sql/</link><pubDate>Wed, 07 Sep 2011 11:36:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/09/%C3%A9viter-les-injections-sql/</guid><description>&lt;p&gt;Nous avons parlé la dernière fois les règles d'
&lt;a href="http://tapoueh.org/blog/2011/08/18-echappements-de-chaine.html"&gt;échappement de chaînes&lt;/a&gt; avec
PostgreSQL, et mentionné qu&amp;rsquo;utiliser ces techniques afin de protéger les
données insérées dans les requêtes SQL n&amp;rsquo;était pas une bonne idée dans la
mesure où PostgreSQL offre une fonctionnalité bien plus adaptée.&lt;/p&gt;
&lt;p&gt;Nous faisons face ici à un problème de sécurité très bien décrit dans le
billet humoristique de
&lt;a href="http://xkcd.com/327/"&gt;Little Boby Tables&lt;/a&gt;, dont je vous recommande la
lecture. L&amp;rsquo;idée est simple, la mise en place de contre mesure fourmille de
pièges subtils, à moins d&amp;rsquo;utiliser la solution décrite ci-après.&lt;/p&gt;</description></item><item><title>Skytools, version 3</title><link>https://tapoueh.org/blog/2011/08/skytools-version-3/</link><pubDate>Fri, 26 Aug 2011 21:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/08/skytools-version-3/</guid><description>&lt;p&gt;You can find
&lt;a href="http://packages.debian.org/source/experimental/skytools3"&gt;skytools3&lt;/a&gt; in debian experimental already, it&amp;rsquo;s in
&lt;em&gt;release
candidate&lt;/em&gt; status. What&amp;rsquo;s missing is the documentation, so here&amp;rsquo;s an idea:
I&amp;rsquo;m going to make a blog post series about
&lt;a href="https://github.com/markokr/skytools"&gt;skytools&lt;/a&gt; next features, how to
use them, what they are good for, etc. This first article of the series
will just list what are those new features.&lt;/p&gt;
&lt;p&gt;Here are the slides from the
&lt;a href="http://www.char11.org/"&gt;CHAR(11)&lt;/a&gt; talk I made last month, about that
very subject:&lt;/p&gt;</description></item><item><title>Échappement de chaînes</title><link>https://tapoueh.org/blog/2011/08/%C3%A9chappement-de-cha%C3%AEnes/</link><pubDate>Thu, 18 Aug 2011 19:01:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/08/%C3%A9chappement-de-cha%C3%AEnes/</guid><description>&lt;p&gt;Parmis les nouveautés de la
&lt;a href="http://www.postgresql.org/about/news.1331"&gt;prochaine version&lt;/a&gt; de
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;, la fameuse
&lt;code&gt;9.1&lt;/code&gt;,
il faut signaler le changement de valeur par défaut de la variable
&lt;code&gt;standard_conforming_strings&lt;/code&gt;, qui passe à
&lt;em&gt;vraie&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;En effet, l&amp;rsquo;utilisation d&amp;rsquo;échappements avec le caractère « anti-slash »
n&amp;rsquo;est pas conforme au standard SQL. Le paramètre
&lt;code&gt;standard_conforming_strings&lt;/code&gt; permet de contrôler le comportement de
PostgreSQL lorsqu&amp;rsquo;il lit une chaîne de caractère dans une requête SQL.&lt;/p&gt;
&lt;p&gt;Voyons quelques exemples :&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;dimitri=# set standard_conforming_strings to true;
SET
dimitri=# select &amp;#39;hop&amp;#39;&amp;#39;&amp;#39;;
 ?column? 
----------
 hop&amp;#39;
(1 ligne)

dimitri=# select &amp;#39;hop\&amp;#39;&amp;#39;;
dimitri&amp;#39;# &amp;#39;;
 ?column? 
----------
 hop\&amp;#39;;
 
(1 ligne)

dimitri=# select E&amp;#39;hop\&amp;#39;&amp;#39;;
 ?column? 
----------
 hop&amp;#39;
(1 ligne)

dimitri=# set standard_conforming_strings to false;
SET
dimitri=# select E&amp;#39;hop\&amp;#39;&amp;#39;;
 ?column? 
----------
 hop&amp;#39;
(1 ligne)

dimitri=# select &amp;#39;hop\&amp;#39;&amp;#39;;
ATTENTION: utilisation non standard de \&amp;#39; dans une cha&amp;amp;#xEE;ne litt&amp;amp;#xE9;rale
LIGNE 1 : select &amp;#39;hop\&amp;#39;&amp;#39;;
 ^
ASTUCE : Utilisez &amp;#39;&amp;#39; pour &amp;amp;#xE9;crire des guillemets dans une cha&amp;amp;#xEE;ne ou utilisez
la syntaxe de cha&amp;amp;#xEE;ne d&amp;#39;&amp;amp;#xE9;chappement (E&amp;#39;...&amp;#39;).
 ?column? 
----------
 hop&amp;#39;
(1 ligne)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Il existe un moyen de forcer PostgreSQL à accepter l&amp;rsquo;utilisation
d&amp;rsquo;échappements avec « anti-slash » indépendamment de la valeur de
&lt;code&gt;standard_conforming_strings&lt;/code&gt;, c&amp;rsquo;est la notation préfixée avec
&lt;code&gt;E&lt;/code&gt;. Il est
recommandé de toujours l&amp;rsquo;utiliser dès lors que la chaîne de caractère
contient des « anti-slash » utilisés comme échappement (du caractère simple
guillemet en général).&lt;/p&gt;</description></item><item><title>See Tsung in action</title><link>https://tapoueh.org/blog/2011/08/see-tsung-in-action/</link><pubDate>Tue, 02 Aug 2011 10:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/08/see-tsung-in-action/</guid><description>&lt;p&gt;&lt;a href="http://tsung.erlang-projects.org/"&gt;Tsung&lt;/a&gt; is an open-source multi-protocol distributed load testing tool and a
mature project. It&amp;rsquo;s been available for about 10 years and is built with
the
&lt;a href="http://www.erlang.org/"&gt;Erlang&lt;/a&gt; system. It supports several protocols, including the
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;
one.&lt;/p&gt;
&lt;p&gt;When you want to benchmark your own application, to know how many more
clients it can handle or how much gain you will see with some new shiny
hardware,
&lt;a href="http://tsung.erlang-projects.org/"&gt;Tsung&lt;/a&gt; is the tool to use. It will allow you to
&lt;em&gt;record&lt;/em&gt; a number of
sessions then replay them at high scale.&lt;br&gt;
&lt;a href="http://pgfouine.projects.postgresql.org/tsung.html"&gt;pgfouine&lt;/a&gt; supports Tsung and is
able to turn your PostgreSQL logs into Tsung sessions, too.&lt;/p&gt;</description></item><item><title>Next month partitions</title><link>https://tapoueh.org/blog/2011/07/next-month-partitions/</link><pubDate>Wed, 27 Jul 2011 22:35:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/07/next-month-partitions/</guid><description>&lt;p&gt;When you do partition your tables monthly, then comes the question of when
to create next partitions. I tend to create them just the week before next
month and I have some nice
&lt;a href="http://www.nagios.org/"&gt;nagios&lt;/a&gt; scripts to alert me in case I&amp;rsquo;ve forgotten
to do so. How to check that by hand in the end of a month?&lt;/p&gt;</description></item><item><title>Preparing for PGCON</title><link>https://tapoueh.org/blog/2011/05/preparing-for-pgcon/</link><pubDate>Thu, 12 May 2011 10:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/05/preparing-for-pgcon/</guid><description>&lt;p&gt;It&amp;rsquo;s this time of the year again, the main international
&lt;a href="http://www.pgcon.org/2011/"&gt;PostgreSQL Conference&lt;/a&gt; is next week in Ottawa, Canada. If previous years are
any indication, this will be great event where to meet with a lot of the
members of your community. The core team will be there, developers will be
there, and we will meet with users and their challenging use cases.&lt;/p&gt;
&lt;p&gt;This is a very good time to review both what you did in the project those
last 12 months, and what you plan to do next year. To help with that,
several
&lt;em&gt;meeting&lt;/em&gt; events are organized. They&amp;rsquo;re like a whole-day round table
with a kind of an agenda, with a limited number of invited people in, and
very intense on-topic discussions about how to organize ourselves for
another great year of innovation in PostgreSQL.&lt;/p&gt;</description></item><item><title>Tables and Views dependencies</title><link>https://tapoueh.org/blog/2011/05/tables-and-views-dependencies/</link><pubDate>Wed, 04 May 2011 11:45:00 +0200</pubDate><guid>https://tapoueh.org/blog/2011/05/tables-and-views-dependencies/</guid><description>&lt;p&gt;Let&amp;rsquo;s say you need to &lt;code&gt;ALTER TABLE foo ALTER COLUMN bar TYPE bigint;&lt;/code&gt;,
and &lt;a href="http://postgresql.org"&gt;PostgreSQL&lt;/a&gt; is helpfully telling you that no you
can&amp;rsquo;t because such and such &lt;em&gt;views&lt;/em&gt; depend on the column. The basic way to
deal with that is to copy paste from the error message the names of the
views involved, then prepare a script wherein you first &lt;em&gt;DROP VIEW&lt;/em&gt; then
&lt;em&gt;ALTER TABLE&lt;/em&gt; and finally &lt;em&gt;CREATE VIEW&lt;/em&gt; again, all in the same transaction.&lt;/p&gt;</description></item><item><title>Dynamic Triggers in PLpgSQL</title><link>https://tapoueh.org/blog/2010/11/dynamic-triggers-in-plpgsql/</link><pubDate>Wed, 24 Nov 2010 16:45:00 +0100</pubDate><guid>https://tapoueh.org/blog/2010/11/dynamic-triggers-in-plpgsql/</guid><description>&lt;p&gt;You certainly know that implementing
&lt;em&gt;dynamic&lt;/em&gt; triggers in
&lt;code&gt;PLpgSQL&lt;/code&gt; is
impossible. But I had a very bad night, being up from as soon as 3:30 am
today, so that when a developer asked me about reusing the same trigger
function code from more than one table and for a dynamic column name, I
didn&amp;rsquo;t remember about it being impossible.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s what happens in such cases, after a long time on the problem (yes,
overall, that&amp;rsquo;s a slow day). Note that I&amp;rsquo;m abusing the
&lt;code&gt;(record_literal).*&lt;/code&gt;
notation a lot in there, and even the
&lt;code&gt;(record_literal).column_name&lt;/code&gt; too.&lt;/p&gt;</description></item><item><title>pg_basebackup</title><link>https://tapoueh.org/blog/2010/11/pg_basebackup/</link><pubDate>Sun, 07 Nov 2010 13:45:00 +0100</pubDate><guid>https://tapoueh.org/blog/2010/11/pg_basebackup/</guid><description>&lt;p&gt;&lt;a href="http://2ndquadrant.com/about/#krosing"&gt;Hannu&lt;/a&gt; just gave me a good idea in
&lt;a href="http://archives.postgresql.org/pgsql-hackers/2010-11/msg00236.php"&gt;this email&lt;/a&gt; on
&lt;a href="http://archives.postgresql.org/pgsql-hackers/"&gt;-hackers&lt;/a&gt;, proposing that
&lt;a href="https://github.com/dimitri/pg_basebackup"&gt;pg_basebackup&lt;/a&gt; should get the
&lt;code&gt;xlog&lt;/code&gt; files again and again in a loop for the
whole duration of the
&lt;em&gt;base backup&lt;/em&gt;. That&amp;rsquo;s now done in the aforementioned
tool, whose options got a little more useful now:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Usage: pg_basebackup.py [-v] [-f] [-j jobs] &amp;#34;dsn&amp;#34; dest

Options:
 -h, --help show this help message and exit
 --version show version and quit
 -x, --pg_xlog backup the pg_xlog files
 -v, --verbose be verbose and about processing progress
 -d, --debug show debug information, including SQL queries
 -f, --force remove destination directory if it exists
 -j JOBS, --jobs=JOBS how many helper jobs to launch
 -D DELAY, --delay=DELAY
 pg_xlog subprocess loop delay, see -x
 -S, --slave auxilliary process
 --stdin get list of files to backup from stdin
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Yeah, as implementing the
&lt;code&gt;xlog&lt;/code&gt; idea required having some kind of
parallelism, I built on it and the script now has a
&lt;code&gt;--jobs&lt;/code&gt; option for you to
setup how many processes to launch in parallel, all fetching some
&lt;code&gt;base backup&lt;/code&gt; files in its own standard (
&lt;code&gt;libpq&lt;/code&gt;)
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; connection, in
compressed chunks of
&lt;code&gt;8 MB&lt;/code&gt; (so that&amp;rsquo;s not
&lt;code&gt;8 MB&lt;/code&gt; chunks sent over).&lt;/p&gt;</description></item><item><title>Extensions: writing a patch for PostgreSQL</title><link>https://tapoueh.org/blog/2010/10/extensions-writing-a-patch-for-postgresql/</link><pubDate>Fri, 15 Oct 2010 11:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/10/extensions-writing-a-patch-for-postgresql/</guid><description>&lt;p&gt;These days, thanks to my
&lt;a href="http://2ndquadrant.com/"&gt;community oriented job&lt;/a&gt;, I&amp;rsquo;m working full time on a
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; patch to terminate basic support for
&lt;a href="http://www.postgresql.org/docs/9/static/extend.html"&gt;extending SQL&lt;/a&gt;. First thing I
want to share is that patching the
&lt;em&gt;backend code&lt;/em&gt; is not as hard as one would
think. Second one is that
&lt;a href="http://git-scm.com/"&gt;git&lt;/a&gt; really is helping.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;“Not as hard as one would think&lt;/em&gt;, are you kidding me?”, I hear some
say. Well, that&amp;rsquo;s true. It&amp;rsquo;s
&lt;code&gt;C&lt;/code&gt; code in there, but with a very good layer of
abstractions so that you&amp;rsquo;re not dealing with subtle problems that much. Of
course it happens that you have to, and managing the memory isn&amp;rsquo;t an
option. That said,
&lt;code&gt;palloc()&lt;/code&gt; and the
&lt;em&gt;memory contexts&lt;/em&gt; implementation makes
that as easy as
&lt;em&gt;in lots of cases, you don&amp;rsquo;t have to think about it&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>Date puzzle for starters</title><link>https://tapoueh.org/blog/2010/10/date-puzzle-for-starters/</link><pubDate>Fri, 08 Oct 2010 10:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/10/date-puzzle-for-starters/</guid><description>&lt;p&gt;The
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;
&lt;code&gt;IRC&lt;/code&gt; channel is a good place to be, for all the very good help
you can get there, because people are always wanting to remain helpful,
because of the off-topics discussions sometime, or to get to talk with
community core members. And to start up your day too.&lt;/p&gt;
&lt;p&gt;This morning&amp;rsquo;s question started simple : “how can I check if today is the
&amp;ldquo;first sunday fo the month&amp;rdquo;. or &amp;ldquo;the second tuesday of the month&amp;rdquo; etc?”&lt;/p&gt;</description></item><item><title>Resuming work on Extensions, first little step</title><link>https://tapoueh.org/blog/2010/10/resuming-work-on-extensions-first-little-step/</link><pubDate>Thu, 07 Oct 2010 17:15:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/10/resuming-work-on-extensions-first-little-step/</guid><description>&lt;p&gt;Yeah I&amp;rsquo;m back on working on my part of the extension thing in
&lt;a href="http://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First step is a little one, but as it has public consequences, I figured I&amp;rsquo;d
talk about it already. I&amp;rsquo;ve just refreshed my
&lt;code&gt;git&lt;/code&gt; repository to follow the
new
&lt;code&gt;master&lt;/code&gt; one, and you can see that here
&lt;a href="http://git.postgresql.org/gitweb?p=postgresql-extension.git;a=commitdiff;h=9a88e9de246218e93c04b6b97e1ef61d97925430"&gt;http://git.postgresql.org/gitweb?p=postgresql-extension.git;a=commitdiff;h=9a88e9de246218e93c04b6b97e1ef61d97925430&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s been easier than I feared, mainly:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ git --no-pager diff master..extension
$ git --no-pager format-patch master..extension
$ cp 0001-First-stab-at-writing-pg_execute_from_file-function.patch ..
$ git checkout master
$ git pull -f pgmaster
$ git reset --hard pgmaster/master
$ git checkout extension
$ git reset --hard master
$ git am -s ../0001-First-stab-at-writing-pg_execute_from_file-function.edit.patch 
$ git status
$ git log --short | head
$ git log -n2 --oneline
$ git push -f
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So that&amp;rsquo;s still more steps that one want to call dead simple, but still. The
&lt;code&gt;format-patch&lt;/code&gt; command is to save my work away (all patches that are in the
&lt;em&gt;extension&lt;/em&gt; branch but not in the
&lt;em&gt;master&lt;/em&gt; — well that was only one of them
here). Then, as the master repository
&lt;code&gt;URL&lt;/code&gt; didn&amp;rsquo;t change, I can simply
&lt;code&gt;pull&lt;/code&gt;
the changes in. Of course I had a nice message
&lt;em&gt;warning: no common commits&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>Window Functions example remix</title><link>https://tapoueh.org/blog/2010/09/window-functions-example-remix/</link><pubDate>Sun, 12 Sep 2010 21:35:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/09/window-functions-example-remix/</guid><description>&lt;p&gt;The drawback of hosting a static only website is, obviously, the lack of
comments. What happens actually, though, is that I receive very few comments
by direct mail. As I don&amp;rsquo;t get another
&lt;em&gt;spam&lt;/em&gt; source to cleanup, I&amp;rsquo;m left
unconvinced that&amp;rsquo;s such a drawback. I still miss the low probability of
seeing blog readers exchange directly, but I think a
&lt;code&gt;tapoueh.org&lt;/code&gt; mailing
list would be my answer, here&amp;hellip;&lt;/p&gt;
&lt;p&gt;Anyway,
&lt;a href="http://people.planetpostgresql.org/dfetter/"&gt;David Fetter&lt;/a&gt; took the time to send me a comment by mail with a
cleaned up rewrite of the previous entry
&lt;code&gt;SQL&lt;/code&gt;, here&amp;rsquo;s it for your pleasure!&lt;/p&gt;</description></item><item><title>Window Functions example</title><link>https://tapoueh.org/blog/2010/09/window-functions-example/</link><pubDate>Thu, 09 Sep 2010 16:35:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/09/window-functions-example/</guid><description>&lt;p&gt;So, when
&lt;code&gt;8.4&lt;/code&gt; came out there was all those comments about how getting
&lt;a href="http://www.postgresql.org/docs/8.4/interactive/tutorial-window.html"&gt;window functions&lt;/a&gt; was an awesome addition. Now, it seems that a lot of people
seeking for help in
&lt;a href="http://wiki.postgresql.org/index.php?title=IRC"&gt;#postgresql&lt;/a&gt; just don&amp;rsquo;t know what kind of problem this
feature helps solving. I&amp;rsquo;ve already been using them in some cases here in
this blog, for getting some nice overview about
&lt;a href="http://tapoueh.org/articles/blog/_Partitioning:_relation_size_per_%E2%80%9Cgroup%E2%80%9D.html"&gt;Partitioning: relation size per “group”&lt;/a&gt;.&lt;/p&gt;
&lt;center&gt;*That's another way to count change*&lt;/center&gt;
&lt;p&gt;Now, another example use case rose on
&lt;code&gt;IRC&lt;/code&gt; today. I&amp;rsquo;ll quote directly our user here:&lt;/p&gt;</description></item><item><title>Synchronous Replication</title><link>https://tapoueh.org/blog/2010/09/synchronous-replication/</link><pubDate>Mon, 06 Sep 2010 18:05:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/09/synchronous-replication/</guid><description>&lt;p&gt;Although the new asynchronous replication facility that ships with 9.0 ain&amp;rsquo;t
released to the wide public yet, our hackers hero are already working on the
synchronous version of it. A part of the facility is rather easy to design,
we want something comparable to
&lt;a href="http://www.drbd.org/"&gt;DRBD&lt;/a&gt; flexibility, but specific to our
database world. So
&lt;em&gt;synchronous&lt;/em&gt; would either mean
&lt;em&gt;recv&lt;/em&gt;,
&lt;em&gt;fsync&lt;/em&gt; or
&lt;em&gt;apply&lt;/em&gt;,
depending on what you need the
&lt;em&gt;standby&lt;/em&gt; to have already done when the master
acknowledges the
&lt;code&gt;COMMIT&lt;/code&gt;. Let&amp;rsquo;s call that the
&lt;em&gt;service level&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>Happy Numbers</title><link>https://tapoueh.org/blog/2010/08/happy-numbers/</link><pubDate>Mon, 30 Aug 2010 11:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/08/happy-numbers/</guid><description>&lt;p&gt;After discovering the excellent
&lt;a href="http://gwene.org/"&gt;Gwene&lt;/a&gt; service, which allows you to subscribe
to
&lt;em&gt;newsgroups&lt;/em&gt; to read
&lt;code&gt;RSS&lt;/code&gt; content (
&lt;em&gt;blogs&lt;/em&gt;,
&lt;em&gt;planets&lt;/em&gt;,
&lt;em&gt;commits&lt;/em&gt;, etc), I came to
read this nice article about
&lt;a href="http://programmingpraxis.com/2010/07/23/happy-numbers/"&gt;Happy Numbers&lt;/a&gt;. That&amp;rsquo;s a little problem that
fits well an interview style question, so I first solved it yesterday
evening in
&lt;a href="http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/List-Processing.html#List-Processing"&gt;Emacs Lisp&lt;/a&gt; as that&amp;rsquo;s the language I use the most those days.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A happy number is defined by the following process. Starting with any
positive integer, replace the number by the sum of the squares of its
digits, and repeat the process until the number equals 1 (where it will
stay), or it loops endlessly in a cycle which does not include 1. Those
numbers for which this process ends in 1 are happy numbers, while those
that do not end in 1 are unhappy numbers (or sad numbers).&lt;/p&gt;</description></item><item><title>Playing with bit strings</title><link>https://tapoueh.org/blog/2010/08/playing-with-bit-strings/</link><pubDate>Thu, 26 Aug 2010 17:45:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/08/playing-with-bit-strings/</guid><description>&lt;p&gt;The idea of the day ain&amp;rsquo;t directly from me, I&amp;rsquo;m just helping with a very
thin subpart of the problem. The problem, I can&amp;rsquo;t say much about, let&amp;rsquo;s just
assume you want to reduce the storage of
&lt;code&gt;MD5&lt;/code&gt; in your database, so you want
to abuse
&lt;a href="http://www.postgresql.org/docs/8.4/interactive/datatype-bit.html"&gt;bit strings&lt;/a&gt;. A solution to use them works fine, but the datatype is
still missing some facilities, for example going from and to hexadecimal
representation in text.&lt;/p&gt;</description></item><item><title>Editing constants in constraints</title><link>https://tapoueh.org/blog/2010/08/editing-constants-in-constraints/</link><pubDate>Mon, 09 Aug 2010 14:45:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/08/editing-constants-in-constraints/</guid><description>&lt;p&gt;We&amp;rsquo;re using constants in some constraints here, for example in cases where
several servers are replicating to the same
&lt;em&gt;federating&lt;/em&gt; one: each origin
server has his own schema, and all is replicated nicely on the central host,
thanks to
&lt;a href="http://wiki.postgresql.org/wiki/Londiste_Tutorial#Federated_database"&gt;Londiste&lt;/a&gt;, as you might have guessed already.&lt;/p&gt;</description></item><item><title>Querying the Catalog to plan an upgrade</title><link>https://tapoueh.org/blog/2010/08/querying-the-catalog-to-plan-an-upgrade/</link><pubDate>Thu, 05 Aug 2010 11:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/08/querying-the-catalog-to-plan-an-upgrade/</guid><description>&lt;p&gt;Some user on
&lt;code&gt;IRC&lt;/code&gt; was reading the releases notes in order to plan for a minor
upgrade of his
&lt;code&gt;8.3.3&lt;/code&gt; installation, and was puzzled about potential needs for
rebuilding
&lt;code&gt;GIST&lt;/code&gt; indexes. That&amp;rsquo;s from the
&lt;a href="http://www.postgresql.org/docs/8.3/static/release-8-3-5.html"&gt;8.3.5 release notes&lt;/a&gt;, and from the
&lt;a href="http://www.postgresql.org/docs/8.3/static/release-8-3-8.html"&gt;8.3.8 notes&lt;/a&gt; you see that you need to consider
&lt;em&gt;hash&lt;/em&gt; indexes on
&lt;em&gt;interval&lt;/em&gt;
columns too. Now the question is, how to find out if any such beasts are in
use in your database?&lt;/p&gt;</description></item><item><title>Database Virtual Machines</title><link>https://tapoueh.org/blog/2010/08/database-virtual-machines/</link><pubDate>Tue, 03 Aug 2010 13:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/08/database-virtual-machines/</guid><description>&lt;p&gt;Today I&amp;rsquo;m being told once again about
&lt;a href="http://www.sqlite.org/"&gt;SQLite&lt;/a&gt; as an embedded database
software. That one ain&amp;rsquo;t a
&lt;em&gt;database server&lt;/em&gt; but a
&lt;em&gt;software library&lt;/em&gt; that you
can use straight into your main program. I&amp;rsquo;m yet to use it, but it looks
like
&lt;a href="http://www.sqlite.org/lang.html"&gt;its SQL support&lt;/a&gt; is good enough for simple things — and that covers
&lt;em&gt;loads&lt;/em&gt; of things. I guess read-only cache and configuration storage would be
the obvious ones, because it seems that
&lt;a href="http://www.sqlite.org/whentouse.html"&gt;SQLite use cases&lt;/a&gt; aren&amp;rsquo;t including
&lt;a href="http://www.sqlite.org/lockingv3.html"&gt;mixed concurrency&lt;/a&gt;, that is workloads with concurrent readers and writers.&lt;/p&gt;</description></item><item><title>Partitioning: relation size per “group”</title><link>https://tapoueh.org/blog/2010/07/partitioning-relation-size-per-group/</link><pubDate>Mon, 26 Jul 2010 17:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/07/partitioning-relation-size-per-group/</guid><description>&lt;p&gt;This time, we are trying to figure out where is the bulk of the data on
disk. The trick is that we&amp;rsquo;re using
&lt;a href="http://www.postgresql.org/docs/current/static/ddl-partitioning.html"&gt;DDL partitioning&lt;/a&gt;, but we want a “nice”
view of size per
&lt;em&gt;partition set&lt;/em&gt;. Meaning that if you have for example a
parent table
&lt;code&gt;foo&lt;/code&gt; with partitions
&lt;code&gt;foo_201006&lt;/code&gt; and
&lt;code&gt;foo_201007&lt;/code&gt;, you would want
to see a single category
&lt;code&gt;foo&lt;/code&gt; containing the accumulated size of all the
partitions underneath
&lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Background writers</title><link>https://tapoueh.org/blog/2010/07/background-writers/</link><pubDate>Mon, 19 Jul 2010 16:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/07/background-writers/</guid><description>&lt;p&gt;There&amp;rsquo;s currently a thread on
&lt;a href="http://archives.postgresql.org/pgsql-hackers/"&gt;hackers&lt;/a&gt; about
&lt;a href="http://archives.postgresql.org/pgsql-hackers/2010-07/msg00493.php"&gt;bg worker: overview&lt;/a&gt; and a series
of 6 patches. Thanks a lot
&lt;em&gt;&lt;strong&gt;Markus&lt;/strong&gt;&lt;/em&gt;! This is all about generalizing a concept
already in use in the
&lt;em&gt;autovacuum&lt;/em&gt; process, where you have an independent
subsystem that require having an autonomous
&lt;em&gt;daemon&lt;/em&gt; running and able to start
its own
&lt;em&gt;workers&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve been advocating about generalizing this concept for awhile already, in
order to have
&lt;em&gt;postmaster&lt;/em&gt; able to communicate to subsystems when to shut down
and start and reload, etc. Some external processes are only external because
there&amp;rsquo;s no need to include them
&lt;em&gt;by default&lt;/em&gt; in to the database engine, not
because there&amp;rsquo;s no sense to having them in there.&lt;/p&gt;</description></item><item><title>Logs analysis</title><link>https://tapoueh.org/blog/2010/07/logs-analysis/</link><pubDate>Tue, 13 Jul 2010 14:15:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/07/logs-analysis/</guid><description>&lt;p&gt;Nowadays to analyze logs and provide insights, the more common tool to use
is
&lt;a href="http://pgfouine.projects.postgresql.org/"&gt;pgfouine&lt;/a&gt;, which does an excellent job. But there has been some
improvements in logs capabilities that we&amp;rsquo;re not benefiting from yet, and
I&amp;rsquo;m thinking about the
&lt;code&gt;CSV&lt;/code&gt; log format.&lt;/p&gt;
&lt;p&gt;So the idea would be to turn
&lt;em&gt;pgfouine&lt;/em&gt; into a set of
&lt;code&gt;SQL&lt;/code&gt; queries against the
logs themselves once imported into the database. Wait. What about having our
next PostgreSQL version, which is meant (I believe) to include CSV support
in
&lt;em&gt;SQL/MED&lt;/em&gt;, to directly expose its logs as a system view?&lt;/p&gt;</description></item><item><title>Using indexes as column store?</title><link>https://tapoueh.org/blog/2010/07/using-indexes-as-column-store/</link><pubDate>Thu, 08 Jul 2010 11:15:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/07/using-indexes-as-column-store/</guid><description>&lt;p&gt;There&amp;rsquo;s a big trend nowadays about using column storage as opposed to what
PostgreSQL is doing, which would be row storage. The difference is that if
you have the same column value in a lot of rows, you could get to a point
where you have this value only once in the underlying storage file. That
means high compression. Then you tweak the
&lt;em&gt;executor&lt;/em&gt; to be able to load this
value only once, not once per row, and you win another huge source of data
traffic (often enough, from disk).&lt;/p&gt;</description></item><item><title>Back from PgCon2010</title><link>https://tapoueh.org/blog/2010/05/back-from-pgcon2010/</link><pubDate>Thu, 27 May 2010 14:26:00 +0200</pubDate><guid>https://tapoueh.org/blog/2010/05/back-from-pgcon2010/</guid><description>&lt;p&gt;This year&amp;rsquo;s edition has been the
&lt;a href="http://www.pgcon.org/2010/"&gt;best pgcon&lt;/a&gt; ever for me. Granted, it&amp;rsquo;s only
my third time, but still :) As
&lt;a href="http://blog.endpoint.com/2010/05/pgcon-hall-track.html"&gt;Josh said&lt;/a&gt; the
&lt;em&gt;&amp;ldquo;Hall Track&amp;rdquo;&lt;/em&gt; in particular was
very good, and the
&lt;a href="http://wiki.postgresql.org/wiki/PgCon_2010_Developer_Meeting"&gt;Dev Meeting&lt;/a&gt; has been very effective!&lt;/p&gt;
&lt;h2 id="extensions"&gt;Extensions&lt;/h2&gt;
&lt;p&gt;This time I prepared some
&lt;a href="http://wiki.postgresql.org/wiki/Image:Pgcon2010-dev-extensions.pdf"&gt;slides to present the extension design&lt;/a&gt; and I tried
hard to make it so that we get to agree on a plan, even recognizing it&amp;rsquo;s not
solving all of our problems from the get go. I had been talking about the
concept and design with lots of people already, and continued to do so while in
Ottawa on Monday evening and through all Tuesday. So Wednesday, I felt
prepared. It proved to be a good thing, as I edited the slides with ideas from
several people I had the chance to expose my ideas to! Thanks
&lt;em&gt;Greg Stark&lt;/em&gt; and
&lt;em&gt;Heikki Linnakangas&lt;/em&gt; for the part we talked about at the meeting, and a lot more
people for the things we&amp;rsquo;ll have to solve later (Hi
&lt;em&gt;Stefan&lt;/em&gt;!).&lt;/p&gt;</description></item><item><title>Finding orphaned sequences</title><link>https://tapoueh.org/blog/2010/03/finding-orphaned-sequences/</link><pubDate>Wed, 17 Mar 2010 13:35:00 +0100</pubDate><guid>https://tapoueh.org/blog/2010/03/finding-orphaned-sequences/</guid><description>&lt;p&gt;This time we&amp;rsquo;re having a database where
&lt;em&gt;sequences&lt;/em&gt; were used, but not
systematically as a
&lt;em&gt;default value&lt;/em&gt; of a given column. It&amp;rsquo;s mainly an historic
bad idea, but you know the usual excuse with bad ideas and bad code: the
first 6 months it&amp;rsquo;s experimental, after that it&amp;rsquo;s historic.&lt;/p&gt;
&lt;center&gt;*Not talking about genome orphaned sequences here, though*&lt;/center&gt;
&lt;p&gt;Still, here&amp;rsquo;s a query for
&lt;code&gt;8.4&lt;/code&gt; that will allow you to list those
&lt;em&gt;sequences&lt;/em&gt;
you have that are not used as a default value in any of your tables:&lt;/p&gt;</description></item><item><title>Getting out of SQL_ASCII, part 2</title><link>https://tapoueh.org/blog/2010/02/getting-out-of-sql_ascii-part-2/</link><pubDate>Tue, 23 Feb 2010 17:30:00 +0100</pubDate><guid>https://tapoueh.org/blog/2010/02/getting-out-of-sql_ascii-part-2/</guid><description>&lt;p&gt;So, if you followed the previous blog entry, now you have a new database
containing all the
&lt;em&gt;static&lt;/em&gt; tables encoded in
&lt;code&gt;UTF-8&lt;/code&gt; rather than
&lt;code&gt;SQL_ASCII&lt;/code&gt;. Because if it was not yet the case, you now severely distrust
this non-encoding.&lt;/p&gt;
&lt;p&gt;Now is the time to have a look at properly encoding the
&lt;em&gt;live&lt;/em&gt; data, those
stored in tables that continue to receive write traffic. The idea is to use
the
&lt;code&gt;UPDATE&lt;/code&gt; facilities of PostgreSQL to tweak the data, and too fix the
applications so as not to continue inserting badly encoded strings in there.&lt;/p&gt;</description></item><item><title>Getting out of SQL_ASCII, part 1</title><link>https://tapoueh.org/blog/2010/02/getting-out-of-sql_ascii-part-1/</link><pubDate>Thu, 18 Feb 2010 11:37:00 +0100</pubDate><guid>https://tapoueh.org/blog/2010/02/getting-out-of-sql_ascii-part-1/</guid><description>&lt;p&gt;It happens that you have to manage databases
&lt;em&gt;designed&lt;/em&gt; by your predecessor,
and it even happens that the team used to not have a
&lt;em&gt;DBA&lt;/em&gt;. Those
&lt;em&gt;histerical
raisins&lt;/em&gt; can lead to having a
&lt;code&gt;SQL_ASCII&lt;/code&gt; database. The horror!&lt;/p&gt;
&lt;p&gt;What
&lt;code&gt;SQL_ASCII&lt;/code&gt; means, if you&amp;rsquo;re not already familiar with the consequences
of such a choice, is that all the
&lt;code&gt;text&lt;/code&gt; and
&lt;code&gt;varchar&lt;/code&gt; data that you put in the
database is accepted as-is. No checks. At all. It&amp;rsquo;s pretty nice when you&amp;rsquo;re
lazy enough to not dealing with
&lt;em&gt;strange&lt;/em&gt; errors in your application, but if
you think that t&amp;rsquo;s a smart move, please go read
&lt;a href="http://www.joelonsoftware.com/articles/Unicode.html"&gt;The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)&lt;/a&gt;
by
&lt;a href="http://www.joelonsoftware.com/"&gt;Joel Spolsky&lt;/a&gt; now. I said now, I&amp;rsquo;m waiting for you to get back here. Yes,
I&amp;rsquo;ll wait.&lt;/p&gt;</description></item><item><title>Resetting sequences. All of them, please!</title><link>https://tapoueh.org/blog/2010/02/resetting-sequences.-all-of-them-please/</link><pubDate>Tue, 16 Feb 2010 16:23:00 +0100</pubDate><guid>https://tapoueh.org/blog/2010/02/resetting-sequences.-all-of-them-please/</guid><description>&lt;p&gt;So, after restoring a production dump with intermediate filtering, none of
our sequences were set to the right value. I could have tried to review the
process of filtering the dump here, but it&amp;rsquo;s a
&lt;em&gt;one-shot&lt;/em&gt; action and you know
what that sometimes mean. With some pressure you don&amp;rsquo;t script enough of it
and you just crawl more and more.&lt;/p&gt;
&lt;p&gt;Still, I think how I solved it is worthy of a blog entry. Not that it&amp;rsquo;s
about a super unusual
&lt;em&gt;clever&lt;/em&gt; trick, quite the contrary, because questions
involving this trick are often encountered on the support
&lt;code&gt;IRC&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>PgCon 2009</title><link>https://tapoueh.org/blog/2009/05/pgcon-2009/</link><pubDate>Wed, 27 May 2009 14:30:00 +0200</pubDate><guid>https://tapoueh.org/blog/2009/05/pgcon-2009/</guid><description>&lt;p&gt;I can&amp;rsquo;t really compare
&lt;a href="http://www.pgcon.org/2009/"&gt;PgCon 2009&lt;/a&gt; with previous years versions, last time I
enjoyed the event it was in 2006, in Toronto. But still I found the
experience to be a great one, and I hope I&amp;rsquo;ll be there next year too!&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve met a lot of known people in the community, some of them I already had
the chance to run into at Toronto or
&lt;a href="http://2008.pgday.org/en/"&gt;Prato&lt;/a&gt;, but this was the first time I
got to talk to many of them about interresting projects and ideas. That only
was awesome already, and we also had a lot of talks to listen to: as others
have said, it was really hard to get to choose to go to only one place out
of three.&lt;/p&gt;</description></item><item><title>Skytools 3.0 reaches alpha1</title><link>https://tapoueh.org/blog/2009/04/skytools-3.0-reaches-alpha1/</link><pubDate>Tue, 14 Apr 2009 00:00:00 +0200</pubDate><guid>https://tapoueh.org/blog/2009/04/skytools-3.0-reaches-alpha1/</guid><description>&lt;p&gt;It&amp;rsquo;s time for
&lt;a href="http://wiki.postgresql.org/wiki/Skytools"&gt;Skytools&lt;/a&gt; news again! First, we did improve documentation of
current stable branch with hosting high level presentations and
&lt;a href="http://wiki.postgresql.org/wiki/Londiste_Tutorial"&gt;tutorials&lt;/a&gt; on
the
&lt;a href="http://wiki.postgresql.org/"&gt;PostgreSQL wiki&lt;/a&gt;. Do check out the
&lt;a href="http://wiki.postgresql.org/wiki/Londiste_Tutorial"&gt;Londiste Tutorial&lt;/a&gt;, it seems that&amp;rsquo;s
what people hesitating to try out londiste were missing the most.&lt;/p&gt;
&lt;p&gt;The other things people miss out a lot in current stable Skytools (version
&lt;code&gt;2.1.9&lt;/code&gt; currently) are cascading replication (which allows for
&lt;em&gt;switchover&lt;/em&gt; and
&lt;em&gt;failover&lt;/em&gt;) and
&lt;code&gt;DDL&lt;/code&gt; support. The new incarnation of skytools, version
&lt;code&gt;3.0&lt;/code&gt;
&lt;a href="http://lists.pgfoundry.org/pipermail/skytools-users/2009-April/001029.html"&gt;reaches alpha1&lt;/a&gt; today. It comes with full support for
&lt;em&gt;cascading&lt;/em&gt; and
&lt;em&gt;DDL&lt;/em&gt;, so
you might want to give it a try.&lt;/p&gt;</description></item><item><title>Importing XML content from file</title><link>https://tapoueh.org/blog/2009/02/importing-xml-content-from-file/</link><pubDate>Thu, 05 Feb 2009 00:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2009/02/importing-xml-content-from-file/</guid><description>&lt;p&gt;The problem was raised this week on
&lt;a href="http://www.postgresql.org/community/irc"&gt;IRC&lt;/a&gt; and this time again I felt it would
be a good occasion for a blog entry: how to load an
&lt;code&gt;XML&lt;/code&gt; file content into a
single field?&lt;/p&gt;
&lt;p&gt;The usual tool used to import files is
&lt;a href="http://www.postgresql.org/docs/current/interactive/sql-copy.html"&gt;COPY&lt;/a&gt;, but it&amp;rsquo;ll want each line of the
file to host a text representation of a database tuple, so it doesn&amp;rsquo;t apply
to the case at hand.
&lt;a href="http://blog.rhodiumtoad.org.uk/"&gt;RhodiumToad&lt;/a&gt; was online and offered the following code
to solve the problem:&lt;/p&gt;</description></item><item><title>Skytools ticker daemon and londiste</title><link>https://tapoueh.org/blog/2009/02/skytools-ticker-daemon-and-londiste/</link><pubDate>Tue, 03 Feb 2009 00:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2009/02/skytools-ticker-daemon-and-londiste/</guid><description>&lt;p&gt;One of the difficulties in getting to understand and configure
&lt;code&gt;londiste&lt;/code&gt;
reside in the relation between the
&lt;code&gt;ticker&lt;/code&gt; and the replication. This question
was raised once more on IRC yesterday, so I made a new FAQ entry about it:
&lt;a href="http://blog.tapoueh.org/skytools.html#ticker"&gt;How do this ticker thing relates to londiste?&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Comparing Londiste and Slony</title><link>https://tapoueh.org/blog/2009/01/comparing-londiste-and-slony/</link><pubDate>Sat, 31 Jan 2009 00:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2009/01/comparing-londiste-and-slony/</guid><description>&lt;p&gt;In the page about
&lt;a href="skytools.html"&gt;Skytools&lt;/a&gt; I&amp;rsquo;ve encouraged people to ask some more questions
in order for me to be able to try and answer them. That just happened, as
usual on the
&lt;code&gt;#postgresql&lt;/code&gt; IRC, and the question is
&lt;a href="skytools.html#slony"&gt;What does londiste lack that slony has?&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Controling HOT usage in 8.3</title><link>https://tapoueh.org/blog/2009/01/controling-hot-usage-in-8.3/</link><pubDate>Wed, 28 Jan 2009 00:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2009/01/controling-hot-usage-in-8.3/</guid><description>&lt;p&gt;As it happens, I&amp;rsquo;ve got some environments where I want to make sure &lt;em&gt;HOT&lt;/em&gt; (
&lt;em&gt;aka Heap Only Tuples&lt;/em&gt;) is in use. Because we&amp;rsquo;re doing so much updates a
second that I want to get sure it&amp;rsquo;s not killing my database server. I not
only wrote some checking view to see about it, but also made
a
&lt;a href="http://www.postgresql.fr/support:trucs_et_astuces:controler_l_utilisation_de_hot_a_partir_de_la_8.3"&gt;quick article&lt;/a&gt; about
it in the &lt;a href="http://postgresql.fr/"&gt;French PostgreSQL website&lt;/a&gt;. Handling
around in &lt;code&gt;#postgresql&lt;/code&gt; means that I&amp;rsquo;m now bound to write about it in
English too!&lt;/p&gt;</description></item><item><title>Londiste Trick</title><link>https://tapoueh.org/blog/2009/01/londiste-trick/</link><pubDate>Wed, 21 Jan 2009 00:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2009/01/londiste-trick/</guid><description>&lt;p&gt;So, you&amp;rsquo;re using
&lt;code&gt;londiste&lt;/code&gt; and the
&lt;code&gt;ticker&lt;/code&gt; has not been running all night
long, due to some restart glitch in your procedures, and the
&lt;em&gt;on call&lt;/em&gt; admin
didn&amp;rsquo;t notice the restart failure. If you blindly restart the replication
daemon, it will load in memory all those events produced during the night,
at once, because you now have only one tick where to put them all.&lt;/p&gt;
&lt;p&gt;The following query allows you to count how many events that represents,
with the magic tick numbers coming from
&lt;code&gt;pgq.subscription&lt;/code&gt; in columns
&lt;code&gt;sub_last_tick&lt;/code&gt; and
&lt;code&gt;sub_next_tick&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>new site, using new software</title><link>https://tapoueh.org/blog/2008/12/new-site-using-new-software/</link><pubDate>Sat, 06 Dec 2008 00:00:00 +0100</pubDate><guid>https://tapoueh.org/blog/2008/12/new-site-using-new-software/</guid><description>&lt;p&gt;Oh and check out the
&lt;a href="skytools.html"&gt;skytools&lt;/a&gt; page too.
&lt;a href="http://mwolson.org/projects/EmacsMuse.html"&gt;Emacs Muse&lt;/a&gt; is so great a project
that instead of just working on how to publish a website with this tool, I
found myself editing a rather large document about
&lt;code&gt;londite.py&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>