openlang

数据库与查询

SQL、索引、事务与任务队列

  1. 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…

    回复 10最近活动 sql
  2. 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…

    回复 3最近活动 sqlgo
  3. 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…

    回复 7最近活动 typescriptsql
  4. 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…

    回复 16最近活动 sql
  5. 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…

    回复 0最近活动 sqlgo
  6. 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…

    回复 6最近活动 sqlgo
  7. 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…

    回复 0最近活动 sql
  8. 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…

    回复 1最近活动 sqlr