Sign in

PostgreSQL Hero

@postgresqlhero.bsky.social
280 followers 2.1K following 281 posts

Want to learn about PostgreSQL? You are in the good place! 🔗 postgresqlhero.alexisbouchez.com

PostsRepliesMedia
PostgreSQL Hero @postgresqlhero.bsky.social · 05/12/2025
ARRAY_AGG is one of those functions you wish you knew about sooner
SQL code showing ARRAY_AGG to collect tags into an array
030
PostgreSQL Hero @postgresqlhero.bsky.social · 05/12/2025
Timezones in SQL be like
Meme: Clock with Roman numerals in wrong positions representing SQL timestamp confusion
020
PostgreSQL Hero @postgresqlhero.bsky.social · 05/12/2025
This is why we have backups. You have backups, right?
Meme: Raccoon firing a golden machine gun with text 'When you're an intern but have prod access (everyone else quit)'
230
PostgreSQL Hero @postgresqlhero.bsky.social · 05/12/2025
When you give AI database access
Meme: Robot with ChatGPT logo saying 'You're absolutely right\!' when asked why it deleted the prod database
130
PostgreSQL Hero @postgresqlhero.bsky.social · 05/12/2025
FUN FACT: postgresqlhero.vercel.app runs a full PostgreSQL database directly in your browser using PGlite. No server. No backend. Just WASM magic under 3MB. Learn SQL for free without us paying a cent for infrastructure 🐘
PGlite homepage - Embeddable Postgres in WebAssembly
011
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
One simple trick to speed up your queries 👇
SQL code: DELETE FROM bad_habits WHERE type = using IN with subqueries
071
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Every MySQL user eventually...
PostgreSQL meme
071
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
PostgreSQL fans be like 🐘
PostgreSQL meme
051
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Top N per group? LATERAL JOIN. The most underrated SQL feature.
SQL code snippet
061
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Division by zero? NULLIF handles it. Returns NULL instead of crashing.
SQL code snippet
051
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Subqueries are unreadable. CTEs are not. Use WITH.
SQL code snippet
052
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Need a comma-separated list from SQL? STRING_AGG. No app code needed.
SQL code snippet
051
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
INSERT or UPDATE? Both. ON CONFLICT DO UPDATE = upsert in one atomic query.
SQL code snippet
051
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Need a list of dates? Don't loop. generate_series() is your friend.
SQL code snippet
042
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
COUNT with conditions? Use FILTER. One query. Multiple counts. No subqueries.
SQL code snippet
161
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
INSERT and get the ID back. One query. Stop doing 2 round trips to your database.
SQL code snippet
051
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
PostgreSQL's secret weapon: DISTINCT ON Get the latest row per group in one query. No window functions needed.
SQL code snippet
041
PostgreSQL Hero @postgresqlhero.bsky.social · 04/12/2025
Stop writing CASE WHEN for null checks. COALESCE exists.
SQL code snippet
041