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

  • Percentage Calculations Using Postgres Window Functions

    Paul Ramsey

    Back when I first learned SQL, calculating percentages over a set of individual contributions was an ungainly business:

    • First calculate the denominator of the percentage,
    • Then join that denominator back to the original table to calculate the percentage.

    This requires two passes of the table: once for the denominator and once for the percentage. For BI queries over large tables (that is, for most BI queries) more passes over the table slow performance significantly.

    Also, the SQL was really ugly!

    With modern PostgreSQL, you can calculate complex percentages over different groups in a single pass

    Read More
  • Postgres Query Boost: Using ANY Instead of IN

    Matt Hudson

    The IN operator has to be in the top-3 SQL-specific operators that people learn, the close competitors are LIKE and BETWEEN. Thus, IN feels familiar when crafting SQL: you can use it with nested SQL statements, or create your own list. But, it does have limitations — what if you wanted to send a list of unknown length? You can’t really use SQL placeholders without also modifying the SQL statement.

    What if I told you there was a less ubiquitous operator that offered all of the power and less of the drawbacks. In this article we'll talk about using = ANY(array)

    Read More
  • 5 min read

    Multi-Cloud Strategies with Crunchy Postgres for Kubernetes

    Joseph Mckulka

    Crunchy Postgres for Kubernetes can be used for cross-datacenter streaming replication out of the box. With so many folks asking for cross-cloud / cross-datacenter replication, we wanted to give people a large explanation of how that works. For this post, we use streaming replication, and prioritize reducing latency and adding stability.

    Cross-cloud streaming replication can be used:

    • To enable multi-cloud disaster recovery
    • For moving clusters between cloud providers
    • For moving clusters between on-premises and cloud
    Read More
  • 5 min read

    Postgres at Scale: Running Multiple PgBouncers

    Elizabeth Christensen

    Multi-PgBouncer is our affectionate in-house name for a special use case of running multiple instances of PgBouncer. PgBouncer is the venerable go-to tool for managing connection pooling at the database layer for Postgres. For some of our customers with notably large databases and high throughput, running multi-PgBouncer has been a great way to keep up with load and connections.

    David Christensen recently did a talk at PGConf.NYC entitled “How to Tame a Mastodon: Lessons for PostgreSQL at Scale

    Read More
  • 5 min read

    Security and Team Management in Crunchy Bridge

    Craig Kerstiens

    I wanted to take a little time today to walk through some of the security and team controls you get out of the box on Crunchy Bridge. Within teams for Crunchy Bridge you have the ability to:

    • Restrict authentication for a team to SSO
    Read More
  • Postgres Insider Terminology

    Paul Ramsey

    Last week Craig Kerstiens published a great introduction to Postgres terminology, covering some of the basics you might run into when just getting started.

    The funny thing about jargon is how quickly we get used to it, and forget we are even using it. It becomes part of the secret handshake, the way we signal to other members of our tribe that we're part of the group.

    When I first started going to Postgres conferences and listening to talks by Postgres core developers I suddenly found myself at sea. What were these strange words and phrases they were using?

    It turns out that a lot of them are taken from the Postgres code base, which in turn naturally uses them because they are part of Codd's relational model

    Read More
  • 11 min read

    Crunchy Bridge's Ruby Backend: Sorbet, Tapioca, and Parlour-Generated Type Stubs

    Brandur Leach

    When we started building Crunchy Bridge two years ago, we chose Ruby as the language to write our database state machine and control plane API. Ruby may not have been the most popular language choice in 2022, but we picked it anyway. A major reason is that everyone on the team already knew it well and liked it. Terse and elegant syntax is perfect for expressing our database state machine logic. Another reason we picked Ruby is that it lets us have a REPL running in production so we can carry out flexible operational work, and expediently thanks to that same terse syntax. Ruby is so efficient for managing a big fleet of servers that it feels a bit like cheating compared to clunky admin dashboards and CLIs.

    But Ruby by itself has a major challenge in that it lacks any kind of built-in mechanism for expressing variable and method type signatures. Every one of us had managed large Ruby codebases in the past and wanted to avoid the quagmire of uncertainty around what the types of anything are supposed to be, which makes code hard to reason about and dangerous to change.

    That's why we chose to type everything with Sorbet

    Read More
  • Data Loading in Postgres for Newbies

    Elizabeth Christensen

    So you’re new to Postgres and you want to test it out and see how it works. Or maybe you’re building a new app and you need to seed your database. How do you get data in your Postgres database? There’s a lot out there on the topic of data migration for Postgres and some of it can be complicated and overwhelming. I’m going to give you some quick and simple ways to get test data IN

    Read More
  • Postgres Databases and Schemas

    Craig Kerstiens

    In my career I've worked on teams that ran and managed over a million databases, and I've helped shard and scale database for customers at 100s of terabytes.

    Postgres is an incredibly flexible database, and because of it's flexibility you have a lot of options for architecting your data design for your application needs. In talking with current customers

    Read More
  • 7 min read

    Easier Upgrades and Image Management for Postgres in Kubernetes

    Andrew L'Ecuyer

    Lukas Fittl recently posted one of his 5 minutes of Postgres videos about his experimentation with different Kubernetes Postgres Operators: Postgres on Kubernetes, choosing the right operator, and handling major version upgrades

    Read More