Smart Postgres News and Techniques 2024 Vol 12

2 Comments

Looking for a Postgres job? Hairetsu put together hiring.fm, which scrapes jobs from over 10,000 company sites (not recruiter spam.) Just put “Postgres” in the search box, pick your country & job type, and whether you want remote. The “Apply” button on each job links out to the company’s site.


Want to think through a challenging data model? You’re familiar with how calendaring apps like Google Calendar and Outlook work, and they make the underlying data seem simple, but designing a data model for it is way harder than it seems, as Alexey Makhotkin shows.


If you have big analytical queries, Elizabeth Christensen explains why you may want to tune Postgres so that queries can go parallel across more than 2 workers.


Technique of the Week:
Recursive CTEs

Say you’ve got a list of employees and you need to build an org chart showing who reports to who. In plain text, it might look like this:

  • CEO
    • CTO
      • Manager of Developers
        • Developer 1
        • Developer 2
      • Manager of Sysadmins
        • Sysadmin 1
        • Sysadmin 2
    • CFO
      • Manager of Accounting
        • Accountant 1
          • Intern 1
          • Intern 2
        • Accountant 2

In an org chart, you have no idea in advance how deep the levels go, and each employee typically has just one manager. For tasks like this, recursive CTEs are a great solution, but not really intuitive to figure out.

Paul Ramsey demonstrates a recursive CTE with a cool data challenge: finding someone’s Kevin Bacon number. He also demonstrates a solution with pgRouting, a graph solver.

Previous Post
Download the Stack Overflow Sample Database for Postgres
Next Post
Announcing Early Access to My Performance Training

2 Comments. Leave new

Leave a Reply to Jeremy Schneider Cancel 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