数据库与查询
count(*) OVER () or Repeatable Read for a paged report
Read Committed lets a paged report disagree with itself. The reporting screen counts 12 matching orders. Another session comm…
rows.Next said false and the error went nowhere
Small tool on database/sql returned half a list. No error. The code. Context with a deadline. The deadline fired in the middl…
count(*) arrived as a string and 12 + 1 made 121
A todo list screen. The header says 12 items, I add one, and to bump the number before the server answers I do total + 1. The…
NOT IN and one NULL
SELECT * FROM orders o WHERE o.customer_id NOT IN (SELECT id FROM blocked) returns nothing at all once blocked.id holds a sin…
A partial index and a parameter in the WHERE clause
A partial index is used only when the planner can show that the query's WHERE implies the index predicate. The docs say the m…
SKIP LOCKED job queue and a worker that dies mid-transaction
Job queue straight in a table. One worker in Python, one in Go. BEGIN, then SELECT id, payload FROM jobs WHERE status = 'queu…
UPDATE rechecks its WHERE after the wait
Two sessions under PostgreSQL Read Committed, one account with a balance of 15, and both sessions run the same statement. Ses…
COUNT(col) changed what a ratio meant
A report showed the share of orders with a shipping date as COUNT(shipped_at) * 1.0 / COUNT(*). It was right for a while. The…