Introducing Crunchy Data Warehouse: A next-generation Postgres-native data warehouse. Crunchy Data Warehouse Learn more

  • PostgreSQL on Linux: Counting Committed Memory

    Greg Smith

    By default Linux uses a controversial (for databases) memory extension feature called overcommit. How that interacts with PostgreSQL is covered in the Managing Kernel Resources

    Read More
  • Better Range Types in Postgres 14: Turning 100 Lines of SQL Into 3

    Jonathan S. Katz

    I can talk about the benefits of PostgreSQL for application development and operations all day. But there two enduring topics that are close to my heart: SCRAM

    Read More
  • 6 min read

    Devious SQL: Run the Same Query Against Tables With Differing Columns

    David Christensen

    We spend time day in, day out, answering the questions that matter and coming up with solutions that make the most sense. However, sometimes a question comes up that is just so darn…interesting that even if there are sensible solutions or workarounds, it still seems like a challenge just to take the request literally. Thus was born this blog series, Devious SQL.

    Devious: "longer and less direct than the most straightforward way."

    The inaugural question

    Read More
  • 5 min read

    Better JSON in Postgres with PostgreSQL 14

    Craig Kerstiens

    Postgres has had "JSON" support for nearly 10 years now. I put JSON in quotes because well, 10 years ago when we announced JSON support we kinda cheated. We validated JSON was valid and then put it into a standard text field. Two years later in 2014 with Postgres 9.4 we got more proper JSON support with the JSONB

    Read More
  • 10 min read

    Simulating UPDATE or DELETE with LIMIT in Postgres: CTEs to The Rescue!

    David Christensen

    There have certainly been times when using PostgreSQL, that I’ve yearned for an UPDATE or DELETE statement with a LIMIT feature. While the SQL standard itself has no say in the matter as of SQL:2016, there are definite cases of existing SQL database dialects that support this.

    Sadly, if you try to do something like this in PostgreSQL, this is the result:

    ERROR:  syntax error at or near "LIMIT"
    LINE 1: DELETE FROM big_table LIMIT 10000;
                                  ^
    
    Read More
  • 5 min read

    PGO 4.7, the Postgres Operator: PVC Resizing, GCS Backups, and More

    Jonathan S. Katz

    We're excited to announce the new version of PGO, the open source Postgres Operator from Crunchy Data version 4.7! There's a lot of really cool features that make it easy to deploy production Postgres clusters on Kubernetes. In this release, we focused on adding enhancements around "Day 2" operations (e.g. PVC resizing), allowing for backups to be stored in Google Cloud Storage

    Read More
  • 4 min read

    Waiting for PostGIS 3.2: ST_InterpolateRaster

    Paul Ramsey

    A common situation in the spatial data world is having discrete measurements of a continuous variable. Every place in the world has a temperature, but there are only a finite number of thermometers: how should we reason about places without thermometers and how should we model temperature?

    For many use cases, the right way to model a continuous spatial variable is a raster: a regularly spaced grid where each square in the grid contains a value of the variable. This works for temperature and precipitation; it works for elevation and slope; it even works for travel times and wayfinding.

    For this blog post, we will build up a temperature surface for Washington State, using the discrete temperature measurements of a set of Department of Transportation (WSDoT) weather stations.

    Getting the Data

    Read More
  • 7 min read

    TLS for Postgres on Kubernetes: OpenSSL CVE-2021-3450 Edition

    Jonathan S. Katz

    Not too long ago I wrote a blog post about how to deploy TLS for Postgres on Kubernetes in attempt to provide a helpful guide from bringing your own TLS/PKI setup to Postgres clusters on Kubernetes. In part, I also wanted a personal reference for how to do it!

    However, some things have changed since I first wrote that post. OpenSSL released a fix for CVE-2021-3450

    Read More
  • Creating a Read-Only Postgres User

    Jonathan S. Katz

    A recent (well depending on when you read this) Twitter discussion mentioned the topic of creating the quintessential "read-only Postgres user" that can, well, only read info from a database, not write to it. A simple way to handle this case is to create a read-only Postgres replica, but that may not make sense based on your application.

    So, how can you simply create a read-only Postgres user (and note that I will use "user" and "role" interchangeably)? Let's explore!

    Background: GRANT, REVOKE, ALTER DEFAULT PRIVILEGES

    Read More
  • 6 min read

    (The Many) Spatial Indexes of PostGIS

    Paul Ramsey

    Spatial indexes are used in PostGIS to quickly search for objects in space. Practically, this means very quickly answering questions of the form:

    • "all the things inside this this" or
    • "all the things near this other thing"

    Because spatial objects are often quite large and complex (for example, coastlines commonly are defined with thousands of points), spatial indexes use "bounding boxes" as index and search keys:

    • Bounding boxes are of a small, fixed size, only 4 floats for a 2D box; and,
    • Bounding boxes are very inexpensive to compare to test things like containment.
    Read More