Quantcast
Channel: Joel on SQL
Browsing latest articles
Browse All 25 View Live

Image may be NSFW.
Clik here to view.

Fun with pg_catalog.pg_depend

Learning PostgreSQL and SQL in general probably begins with the concept of TABLES. Then probably VIEWS, INDEXES and maybe TRIGGERS. Some users might not ever go any further, which is sad, because there...

View Article



Image may be NSFW.
Clik here to view.

SET search_path for all SECURITY DEFINER functions

As pointed out by Peter Eisentraut in a blog post named Schema Search Paths Considered Pain in the Butt, you need to make sure the search_path is explicitly set for all SECURITY DEFINER functions in...

View Article

Image may be NSFW.
Clik here to view.

Garbage Collection of Unused PostgreSQL Tables and Columns

Over the last five years, our database at Trustly have kept growing in number of tables, columns and functions, where some of the tables and columns aren’t being used by any database functions any...

View Article

Image may be NSFW.
Clik here to view.

psql \watch 1400000000 epoch time countdown counter

SET TIMEZONE TO 'UTC'; \t \a \pset fieldsep ' ' SELECT (('epoch'::timestamptz + 14*10^8 * '1 s'::interval)-now())::interval(0), (14*10^8-extract(epoch from now()))::int, extract(epoch from now())::int...

View Article

Image may be NSFW.
Clik here to view.

“How we use PostgreSQL at Trustly” at PGConf.EU

Slides from my talk, How we use PostgreSQL at Trustly, are now available.

View Article


Image may be NSFW.
Clik here to view.

Finding missing foreign keys

By coincidence I stumbled upon a table where one of its columns didn’t have a foreign key. I found this strange, since our convention is to always add foreign keys when appropriate. But humans are...

View Article

Image may be NSFW.
Clik here to view.

Pgcronjob: Cron daemon to run user defined functions

I find myself quite often having to split a large write operation such as updating millions of rows in a heavily used table. This usually boils down to writing a small Perl script that runs a small...

View Article

Image may be NSFW.
Clik here to view.

PgTerminator: Kill misbehaving db users if important processes are waiting

If you are a DBA and ever have had to manually call pg_terminate_backend() to kill some misbehaving backend process, then this tool might be of interest. Long running queries are not a problem, as long...

View Article


Image may be NSFW.
Clik here to view.

pg_catalog visualized

I couldn’t find any graph showing all the relations between all the pg_catalog tables, so just for fun I wrote a little script to parse the SGML and generate a graph using GraphViz. #!/usr/bin/perl use...

View Article


Using pg_badplan to CREATE STATISTICS is a good plan

Thanks to Thomas Vondra’s presentation CREATE STATISTICS – What is it for? at Nordic PGDay 2018, my Trustly colleague Claes Jakobsson came up with the idea for a new extension. The presentation...

View Article
Browsing latest articles
Browse All 25 View Live




Latest Images