
SQL editor, scheduler, and pipelines in one native Mac app. Daily notes for people who write queries.
Joined October 2026
- Tweets798
- Following169
- Followers49
- Likes999
QueryFlow retweeted
Supplier CSVs have the same headers in a different order? DuckDB can align them by name:
SELECT * FROM read_csv('quotes/*.csv', header=true, union_by_name=true);
Standardize the headers first. This won't tell you whether price and unit_price mean the same thing, or reconcile USD with EUR. Name-based alignment also uses more memory.
Docs reviewed; not tested.
github.com/duckdb/duckdb
#GitHub #DataTools #InternationalTrade
QueryFlow retweeted
Cloud ops metadata as Iceberg tables means "which buckets grew last month?" becomes a SQL query instead of console clicks.
The real win is joins across services, like AWS's own example: Glue tables no Athena query has read in 90 days. Databricks system tables already do this for the lakehouse, cost data included. xitter.cf/awswhatsnew/status/212…
QueryFlow retweeted
Monday brings #AI
Before trusting AI-written ad revenue SQL, test two impressions worth 1¢ each, where one matches two tracking events. The right total is 2¢. A plain SUM after the join gives 3¢, and SUM(DISTINCT revenue) gives 1¢.
QueryFlow retweeted
Postgres tip: if CREATE INDEX CONCURRENTLY fails, it leaves an INVALID index behind. Queries ignore it, but every write still pays to keep it updated. A retry with IF NOT EXISTS just sees the name and skips. Drop it and run it again.
QueryFlow retweeted
Asked Postgres for 10 failed rows ordered by ID and it scanned 10,000,000 rows (1,461 ms).
Why: failures clump at the tail, so walking the PK index discards millions of healthy rows first. A Bitmap Heap Scan drops it to 9.6 ms.
encountered Postgres' query planner again and wrote about it.
blog.mchl.xyz/post/expressio…
QueryFlow retweeted
Top 10 PostgreSQL mistakes that show up in prod:
1) SELECT * on hot paths. Wider rows, more IO, harder index-only scans, slower upgrades when columns grow.
2) No indexes for real queries. Filtering on user_id + status but only indexing user_id, then wondering why p95 jumps at 10M rows.
3) Adding indexes blindly. Every extra index slows writes, vacuum, and increases bloat. Measure before and after.
4) Missing composite index order. (a,b) helps a=… AND b=… and a=…, not b=… alone.
5) OFFSET pagination at scale. OFFSET 100000 still scans 100000. Use keyset pagination (WHERE id > last_id ORDER BY id LIMIT 50).
6) Long transactions. Autovacuum can’t clean dead tuples, replicas lag, and locks stick around longer than you think.
7) Ignoring VACUUM/autovacuum tuning. Default settings + write-heavy tables = bloat and surprise slowdowns weeks later.
8) No connection pooling. 500 pods each opening 20 conns turns into 10k backends, context switching, and memory pressure. Use pgbouncer.
9) Weak timeouts + retries. No statement_timeout, retries without jitter, and you amplify load during incidents.
10) No EXPLAIN (ANALYZE, BUFFERS) + poor observability. You ship a query, it regresses, and you have no slow query logs or pg_stat_statements to prove where the time went.
[generated using my AI agent, hope you learnt something]
QueryFlow retweeted
Hit Save, read from a replica, still see the old value. Classic.
#PostgreSQL 19 adds WAIT FOR LSN: a session on a read replica waits until the replica has replayed up to a given WAL position, then runs the query.
So the replica catches up to that write before you read.
MySQL InnoDB compression is still unstable. A lot of systems used table compression in the past, but later the official maintainers wanted to push page compression. However, because it relies too heavily on the file system, page compression never really took off. It's such a shame. dev.mysql.com/blog-archive/i…
QueryFlow retweeted
A gateway webhook and the customer's return to the order received page can both complete one WooCommerce order. Each holds an unpaid copy, so the order emails go out twice. We now take a MySQL GET_LOCK per order and re-read it first. How do you guard yours?
QueryFlow retweeted
Zero to Hundred had Stripe calls running inside Postgres transactions
Each one held a connection from a 20 connection pool while Stripe took its time
CI now fails on any new one
QueryFlow retweeted
When importing data in #Excel or #PowerBI via #PowerQuery, it is a good idea to set the column data types. But for wide tables is that this can take a lot of time as you have to wait for Power Query to catch up. 🙈 Here's how to quickly set ALL data types: youtube.com/watch?v=KGvfqm1n…
QueryFlow retweeted
Check out my latest article: PostgreSQL benchmarking: results, scripts and a small fire linkedin.com/pulse/postgresq… przez @LinkedIn
QueryFlow retweeted
GitHub moved 130 of its busiest database tables to new machines without holding off writes for more than only a few tens of milliseconds
For more than ten years most of GitHub sat on one main MySQL cluster. Users, repos, issues, PRs, all of it. An incident there hit everything at once, and the only way to scale was buying bigger machines
The move was kinda boring by the time it happened. The app was already treating those tables like a separate database long before anything moved
First they grouped tables that get joined and written together. Gists live with gist comments and starred gists, that kind of thing
Then they added checks that fail any query touching tables from two different groups, plus a sampled one in production that flags transactions crossing groups.
When a feature really needed both sides in one transaction, they moved that data into the same group so it stays on one machine. A group with zero crossings is safe to move
I love how small the actual cutover is. The new cluster just copies from the old one like any replica. Then a script makes the old primary read only, waits for the last change to land, stops copying, points the app at the new cluster and turns writes back on. Done at the quietest hour, it caused a handful of failed writes only
In 2019 that one cluster was serving 950K queries a second. By 2021 the same tables spread across several clusters were serving 1.2M, and the average load per machine had halved
github.blog/engineering/infr…
QueryFlow retweeted
If CREATE INDEX CONCURRENTLY fails, Postgres leaves an INVALID index behind. The planner skips it, but every write still pays to maintain it.
I found one on a payments table months after a migration timed out.
Query in the image. I run it after every index migration now.
QueryFlow retweeted
The request took 2 seconds.
The query took 200 ms.
The other 1.8 seconds? Waiting for a database connection.
Check pool occupancy and how long requests hold connections. Follow the longest span first.
One Order, Thirteen Field Notes · 07/13
QueryFlow retweeted
🐘 PostgreSQL 19 vs 🦀 PgRust vs TimescaleDB
How fast can they import 10 MILLION CSV rows?
🐘 PostgreSQL 19.0 → 9.63s
🦀 PgRust 0.4-beta → 10.75s
🐘 PostgreSQL 18.7 → 10.99s
⏱️ TimescaleDB (regular table) → 11.24s
Same hardware. Same dataset. Warm cache. Median of 10 runs.
PostgreSQL 19 is 14% faster than PostgreSQL 18.
PgRust is still in beta and already outperforming PostgreSQL 18.
The future of PostgreSQL looks exciting.
xitter.cf/alxshp/status/21256519…
PostgreSQL 19 wins the race 🐘🚀
How long does it take to import 1 million CSV rows?
🐘 PostgreSQL 19 → 1.85 seconds
🐘 PostgreSQL 16 → 2.47 seconds*
🦭 MariaDB 10.11 → 3.05 seconds*
🐬 MySQL 26.10 → 5.03 seconds
🐘 PostgreSQL 18 → 5.60 seconds*
🦭 MariaDB 12.3 → 7.60 seconds*
🐬 MySQL 9.7 → 11.20 seconds*
PostgreSQL used COPY. MySQL and MariaDB used LOAD DATA.
xitter.cf/alxshp/status/21234711…
QueryFlow retweeted
Stop guessing which SQL query is slowing down your Postgres database.
Enable `pg_stat_statements`.
It tracks execution statistics across ALL queries run by your application.
The Query to find the biggest CPU hogs in your database:
```sql
SELECT
round(total_exec_time::numeric, 2) AS total_ms,
calls,
round(mean_exec_time::numeric, 2) AS avg_ms,
query
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 5;
```
Why this is 10x better than inspecting slow query logs:
• A query that takes 10ms doesn't show up in slow query logs (threshold usually > 100ms).
• BUT if that query runs 1,000,000 times an hour:
10ms * 1,000,000 = 10,000 seconds of total CPU time!
It is consuming 80% of your database capacity in aggregate.
`total_exec_time` reveals the hidden micro-queries silently melting your database.
Add to `postgresql.conf`:
`shared_preload_libraries = 'pg_stat_statements'`
Restart Postgres, and turn on the lights in your database.
QueryFlow retweeted
Introducing pgPrism 🐘
EXPLAIN plans, refracted.
A tiny Postgres plan visualizer you can embed anywhere.
→ blogs
→ docs
→ dashboards
→ reports
One script tag. Every <pre> plan lights up.
⚡ 0 dependencies
⚡ 37 KiB gzipped
⚡ BUFFERS first: blocks → bytes (hit=16636 → 130 MiB)
⚡ Finds what's wrong. Jumps to the node.
⚡ Table. Tree. Flame.
⚡ JSON plans → Postgres text plans (jsonToText)
⚡ Copy for LLM
No framework. No build step. No backend.
Postgres 15–19.
Open source – GitHub link below























