• 9 min read

    Auto-archiving and Data Retention Management in Postgres with pg_partman

    Keith Fiske

    You could be saving money every month on databases costs with a smarter data retention policy. One of the primary reasons, and a huge benefit of partitioning is using it to automatically archive your data. For example, you might have a huge log table. For business purposes, you need to keep this data for 30 days. This table grows continually over time and keeping all the data makes database maintenance challenging. With time-based partitioning, you can simply archive off data older than 30 days....

    Read More
  • Building PostgreSQL Extensions: Dropping Extensions and Cleanup

    David Christensen

    I recently created a Postgres extension which utilizes the extension to schedule recurring activities using the . Everything worked great. The only problem was when I dropped my extension, it left the cron job scheduled, which resulted in regular errors: If you look in the table, you can see the SQL for the cron job is still present, even though the extension/schema isn’t: This got me thinking: how can you create a Postgres extension that can clean up after itself for cases like this? If...

    Read More
  • 3 min read

    Row Level Security for Tenants in Postgres

    Craig Kerstiens

    Row-level security (RLS) in Postgres is a feature that allows you to control which rows a user is allowed to access in a particular table. It enables you to define security policies at the row level based on certain conditions, such as user roles or specific attributes in the data. Most commonly this is used to limit access based on the database user connecting, but it can also be handy to ensure data safety for multi-tenant applications. We're going to assume our tenants in this case are part o...

    Read More
  • 8 min read

    Contributing to Postgres 101: A Beginner's Experience

    Elizabeth Christensen

    I recently got my very first patch into PostgreSQL! To be clear I'm not a C developer and didn't contribute some fancy new feature. However, I do love Postgres and wanted to contribute. Here's my journey and what I learned along the way. I had an idea for a docs patch while I was talking to Stephen Frost about some research and writing I was doing about HOT updates and fill factor . A recent update to HOT updates meant HOT could be compatible with BRIN. And while the HOT readme was up to date,...

    Read More
  • 5 min read

    Inside PostGIS: Calculating Distance

    Paul Ramsey

    Calculating distance is a core feature of a spatial database, and the central function in many analytical queries. • "How many houses are within the evacuation radius?" • "Which responder is closest to the call?" • "How many more miles until the school bus needs routine maintenance?" "How many houses are within the evacuation radius?" "Which responder is closest to the call?" "How many more miles until the school bus needs routine maintenance?" PostGIS and any other spatial database let you answ...

    Read More
  • Examining Postgres Upgrades with pg_upgrade

    Greg Sabino Mullane

    Postgres is an amazing database system, but it does come with a five-year life cycle. This means you need to perform a major upgrade of it at least every five years. Luckily, Postgres ships with the program, which enables a quick and easy migration from one major version of Postgres to another. Let's work through an example of how to upgrade - in this case, we will go from Postgres 12 to Postgres 16. You should always aim to go to the highest version possible. Check postgresql.org to see what...

    Read More
  • Postgres Performance Boost: HOT Updates and Fill Factor

    Elizabeth Christensen

    There’s a pretty HOT performance trick in Postgres that doesn’t get a ton of attention. There’s a way for Postgres to only update the heap (the table), avoiding having to update all the indexes. That’s called a HOT update , HOT stands for heap only tuple. Understanding HOT updates and their interaction with page fill factor can be a really nice tool in the box for getting performance with existing infrastructure. I’m going to review HOT updates and how to encourage them in your Postgres updates...

    Read More
  • 6 min read

    Connecting QGIS to Postgres and PostGIS

    Elizabeth Christensen

    QGIS, the Quantum Geographic Information System, is an open-source graphical user interface for map making. QGIS works with a wide variety of file types and has robust support for integrating with Postgres and PostGIS. Today I just wanted to step through getting QGIS connected to a Postgres database and the basic operations that let you connect the two systems. Connecting QGIS to Postgres is very similar to any other GUI or application, you’ll need the database host, login, and password details....

    Read More
  • 4 min read

    Migrate from Heroku Postgres to Crunchy Bridge

    Craig Kerstiens

    While database migrations are not an everyday thing for you, they are for us. Migrating to a new database provider isn't something you ever take lightly. Once you've come to the decision that you may want to migrate then you look at the time and effort cost of switching, only to wonder if it's really worth it. You decide it is, and still you're left with uncertainty of what-if: • What about Postgres versions? • What about Postgres extensions? • What about collations? • How do you minimize cutove...

    Read More
  • The Rest is History: Investigations of WAL History Files

    Brian Pace

    PostgreSQL uses the concept of a timeline to identify a series of WAL records in space and time. Each timeline is identified by a number, a decimal in some places, hexadecimal in others. Each time a database is recovered using point in time recovery and sometimes during standby/replica promotion, a new timeline is generated. A common mistake is to assume that a higher timeline number is synonymous with the most recent data. While the highest timeline points to the latest incarnation of the datab...

    Read More