Smart Postgres News and Techniques 2024 Vol 4

2 Comments

When you wanna make big database deployments with as little downtime as possible, it’s time to learn to use Amazon’s fully managed blue/green deployments. If you’re not familiar with the topic, start with this topic primer before reading Amazon’s docs, then read these testimonials on HackerNews.


When you need to read data before you modify it, don’t. Hahaha, easy for me to say, right? Craig Ringer explains why in more detail, and gives alternatives including single-statement updates and isolation level hints.


10 underrated features of PostgreSQL by Chris Travers. The post over a decade old, and yet there are still gems in here that don’t get enough use today, like functional indexes and partial indexes.


When you want to make a query run faster, the first place to start is by reading its explain plan. That page is a good primer on how to get a query’s explain plan and interpret the output.


Technique of the Week:
Getting Tuning Help

When you need help tuning a query, and you’re okay with sharing the query publicly, get the explain plan by putting this before the query, and then running it:

Execute the query, and instead of getting query results, you’ll get the plan in JSON format. Copy that, and then open explain.dalibo.com and paste it into the plan box. Copy/paste the query into the query box as well. When you hit submit, your query plan will be shown publicly – that’s important, because you don’t wanna share anything that your company wouldn’t wanna see online. (If you don’t like those graphical plans, another plan-sharing option is explain.depesz.com.)

Save that link, and then go to a Q&A site like:

Then keep your browser open to that page for at least 30 minutes. In the first 30 minutes, comments often come in fast & furious – not necessarily answers, but comments that are trying to help you refine the question and brainstorm different solutions. The more interactive you are in those first 30 minutes, the better answer you’ll eventually get.

Previous Post
Query Exercise: Find the Best Time for Maintenance
Next Post
Find the Best Time for Maintenance: Answers & Discussion

2 Comments. Leave new

  • Jeremy Schneider
    January 23, 2024 11:28 am

    Nice post! Depesz and Dalibo are my go-to for query plans too. Two things I think might be worth adding: (1) If folks work at a company where there’s concern about pasting plans on the internet, both depesz and dalibo tools are open source and it’s possible to run your own installation behind your corporate firewall. I know of at least one large company doing this. (2) If folks work at a company where they already have slack open all day, then maybe worth mentioning there’s a pretty active community Postgres Slack as well (I see some of the same people hanging out and helping with questions on both slack and discord). The most official-ish invite link for the slack is currently at http://pgtreats.info/slack-invite

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed