Topic

SQL

Discover SQL best practices covering query optimization, database design, normalization, and relational database management. Our digest aggregates ACID compliance, transaction patterns, and distributed query from developer communities.

What this topic tracks

  • Database releases and ecosystem updates
  • Query, indexing, and modeling practices
  • Operational lessons from production systems

SQL · 84 stories

Recent stories

Each story's summary, with the places it was discussed.

Summaries are written by AI from the linked sources. Open the source for full context.

20 stories

The infamous 20 year old MySQL Bug #11472 has been fixed.

bugs.mysql.com · 25 May

Database · MySQL · SQL

A persistent MySQL bug, identified in 2005, caused triggers to fail during cascading foreign key operations.

After 20 years of community discussion and controversy regarding database integrity, the issue has finally been resolved as part of WL#17024, enabling triggers on referenced tables during cascade events.

t8y2/dbx

github.com · 29 Sept

Artificial Intelligence · Database · SQL

DBX is a lightweight, open-source, cross-platform database client that consolidates 100+ databases and middleware in a roughly 25 MB application.

It combines desktop, Web, Docker, and CLI interfaces with an AI SQL assistant, MCP Server integration, schema/data tools, plugins, encryption, and safety controls—distinguished by broad coverage without runtime bloat.

What ORMs have taught me: just learn SQL

wozniak.ca · 5 Jul

Database · PostgreSQL · SQL

The author argues that Object-Relational Mappers (ORMs) often cause more problems than they solve due to issues like attribute creep, complex foreign key joins, and the Object-Relational Impedance Mismatch.

Instead of relying on ORMs for query generation, the author advocates for mastering SQL and treating the database as an API-driven data type.

Prefer Strict Tables in SQLite

evanhahn.com · 11 Jul

Database · SQL · SQLite

SQLite strict tables, introduced in version 3.37.0, enforce rigid data typing by preventing invalid type insertions and bogus column declarations.

While strict tables add validation overhead and require table recreation for migration, they improve data integrity and prevent subtle bugs caused by SQLite's default flexible typing, despite the official advocacy for flexible schemas.

Training a 4B model to produce 81% faster query plans than Postgres

rohanbansal.com · 16 Sept

Database · PostgreSQL · SQL

Rohan Bansal trained a 4B open-weights model with supervised fine-tuning and agentic reinforcement learning to improve PostgreSQL query plans through pg_hint_plan.

Careful cache-noise control and custom rewards were essential. On the 113-query JOB benchmark, best-of-15 selection achieved 1.81× geometric-mean speedup and a 44.7% latency reduction versus PostgreSQL defaults, demonstrating niche domain training’s potential.

Please, I beg you, we need to stop using Stored Procedures (from applications)

heffree.dev · 30 Aug

Database · Performance · SQL

The author argues that applications should usually avoid Stored Procedures, because parameterized queries and plan caching provide equivalent DBMS benefits while keeping database logic versioned with application code.

They urge developers to learn SQL and collaborate with DBAs, emphasizing fewer network requests, indexes, profiling, ORM query inspection, avoiding N+1 and Cartesian explosions, and careful dynamic-query design, conversions, TVPs, and filtered indexes.

The perils of UUID primary keys in SQLite

andersmurphy.com · 5 Jun

Database · SQL · SQLite

Using random UUID4 as primary keys in SQLite leads to significant performance degradation due to B-tree rebalancing and increased paging.

Performance testing reveals that UUID4 inserts are 10-12 times slower than integer primary keys. Switching to time-ordered UUID7 effectively mitigates these issues, bringing performance near baseline levels despite the larger byte size of UUIDs.

The startup's Postgres survival guide

hatchet.run · 22 Jul

Database · PostgreSQL · SQL

This guide covers essential Postgres management for startups, emphasizing iterative schema design, performance-oriented querying with indices, and effective connection management.

It covers intermediate topics like the query planner, query optimization with EXPLAIN ANALYZE, balancing autovacuum settings to prevent bloat, and advanced strategies such as partitioning and FOR UPDATE SKIP LOCKED to ensure production reliability.

SQLite should have (Rust-style) editions

mort.coffee · 15 Jul

Database · SQL · SQLite

The author argues that SQLite should adopt a versioned 'editions' system similar to Rust.

Currently, SQLite’s default settings—such as disabled foreign key constraints, loose type affinity, and lack of busy-timeouts—often lead to bugs and poor performance. An edition-based approach would allow for modernizing global defaults while maintaining backward compatibility.

DuckDB Internals: Why Is DuckDB Fast? (Part 1)

greybeam.ai · 16 Jun

Database · SQL · Computer Science

DuckDB is a rapidly adopted, high-performance, in-process analytical SQL database designed for efficiency.

Unlike server-based engines, it runs within the client application, avoiding network and serialization overhead. This analysis details its front-end architecture—covering parsing, binding, cost-based optimization, physical planning, and storage layer—explaining how it enables lightning-fast queries on formats like Parquet, CSV, and internal binary files.

It's 2026, Just Use Postgres

tigerdata.com · 2 Feb

Database · PostgreSQL · SQL

This article challenges the 'use the right tool for the right job' mantra that often leads developers to manage multiple specialized databases (Elasticsearch, Pinecone, Redis, etc.).

Such sprawl creates technical debt, complex security models, and high operational costs. Instead, the author advocates for using PostgreSQL as a unified platform. Innovations like pgvector (vector search), TimeScaleDB (time-series), and pg_textsearch (BM25 search) allow Postgres to match specialized tools' performance using similar algorithms. This simplification is especially critical in the AI era, where maintaining consistent data for agents is easier within a single, atomic environment. The post concludes that 99% of companies can achieve their goals with Postgres alone, reducing architecture fragmentation and potential failure points.

ggsql: A Grammar of Graphics for SQL

opensource.posit.co · 20 Apr

Data Science · SQL · Business

Posit has released the alpha version of ggsql, a tool that implements the grammar of graphics using SQL syntax.

It enables structured, code-based data visualization directly within SQL queries. Designed for performance and reproducibility, ggsql integrates with tools like Quarto and Jupyter, aiming to provide a powerful, language-agnostic visualization solution for data analysts and SQL users.

PostgreSQL for Everything

raphaelbauer.com · 19 Aug

Database · Software Architecture · SQL

PostgreSQL is presented as a stable, scalable, and versatile open-source RDBMS that can simplify IT by combining database, full-text search, JSON storage, queues, time-series processing, vector retrieval, caching, binary data handling, hierarchical queries, and JSON APIs.

Extensions such as Timescale, pgvector, and pgai broaden its capabilities, often reducing the need for specialized systems.

Things you didn't know about (Postgres) indexes

jon.chrt.dev · 15 Apr

Database · PostgreSQL · SQL

Database indexes speed up read operations by acting like sorted references, similar to a book index.

However, they introduce overhead for writes and storage. Key optimization strategies include understanding composite indexes, using functional indexes for expressions, implementing partial indexes for filtered datasets, and leveraging covering indexes for index-only scans. Always measure performance using EXPLAIN and EXPLAIN ANALYZE.

Joins are NOT Expensive

database-doctor.com · 30 Mar

Database · Performance · SQL

This analysis challenges the misconception that frequent database joins are expensive, instead showing they are efficient and scalable.

Using DuckDB and PostgreSQL benchmarks, it demonstrates that 'One Big Table' (OBT) models often consume more CPU due to data reassembly and projection costs. Dimensional modeling, as advocated by Ralph Kimball, remains superior for analytical performance.

DuckDB 2.0.0 LTS "Cinnamon Teal"

duckdb.org · 21 Oct

Database · SQL

DuckDB 2.0.0 LTS, codenamed “Cinnamon Teal,” is its largest feature release, built through nearly 20,000 commits since 1.5.

It adds a polished Quack client-server protocol, CONNECT, asynchronous Parquet/CSV I/O, first-class VARIANT, CLI agent mode, extensible PEG parser, C API v2, triggers, and SQL additions including NEAREST joins. It requires C++17, supports through at least October 2027, and introduces storage compatibility considerations: pre-2.0 versions cannot read files created by 2.0.

What are skiplists good for?

antithesis.com · 16 Apr

Data Science · Database · SQL

A skiplist is a randomized data structure providing logarithmic performance via layered, probabilistic links.

The author describes solving a complex tree-traversal problem in a data warehouse by inventing a 'skiptree'—a hierarchical structure of skiplists stored in SQL tables. This technique enabled efficient ancestor lookups using joins, demonstrating how exotic data structures can solve unique database performance challenges.

Where it came fromHacker NewsRedditLobstersGitHubCreate a Snapbyte.dev digest and choose SQL as one of your topics.Build your digest