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 · 85 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

5NF and Database Design

kb.databasedesignbook.com · 11 Apr

Database · Software Architecture · SQL

This article demystifies the fifth normal form (5NF) by advocating for a logical design approach rather than traditional, confusing decomposition methods.

By starting with business requirements and clear logical models—specifically the AB-BC-AC triangle and the ABC+D star patterns—developers can create fully normalized database schemas without manual splitting or artificial constraints.

Show HN: Postgres extension for BM25 relevance-ranked full-text search

github.com · 31 Mar

Database · PostgreSQL · SQL

pg_textsearch is a high-performance PostgreSQL extension providing BM25 ranking for text search.

It features simple syntax, Block-Max WAND optimization for fast top-k queries, and parallel index builds. Designed for production, it supports PostgreSQL 17-18, partitioning, and configurable ranking parameters, making it a scalable alternative for textual information retrieval within the database.

Chess in SQL

dbpro.app · 29 Mar

Database · Programming Languages · SQL

This article demonstrates how to render and play a chess game using only SQL.

By utilizing a table to store piece positions, conditional aggregation to pivot data into an 8x8 grid, and basic CRUD operations to execute turns, the author shows that SQL is capable of complex game visualization and logic without frontend frameworks or JavaScript.

How we made geo joins 400× faster with H3 indexes

floedb.ai · 5 Feb

Big Data · Database · SQL

Geospatial joins, which use spatial predicates like ST_Intersects, often suffer from performance issues at scale due to their quadratic complexity.

While conventional joins utilize efficient hash partitioning, spatial predicates lack a clean join key, forcing expensive row-by-row comparisons. Floe addresses this by automatically rewriting queries to utilize H3 indexes, a hexagonal hierarchical tiling system that converts complex geometries into big-integer cell IDs. By representing shapes as sets of H3 cells, the system performs a fast integer equi-join as a pre-filter, followed by an exact spatial recheck to eliminate false positives. This method effectively reduces candidate pairs by up to 99 percent. Benchmark results show that optimizing H3 resolution can lead to speedups of nearly 400x compared to baseline queries, transforming expensive spatial operations into efficient parallel hash joins.

l: A new runtime for k and q

lv1.sh · 7 Jul

Database · Performance · SQL

The l platform offers full compatibility with k4, q, and qSQL, enabling seamless integration without code rewrites.

It natively supports columnar tables, dictionaries, partitions, and splays, ensuring high performance and immediate interoperability for existing infrastructure.

Full-Text Search with DuckDB

peterdohertys.website · 29 Apr

Database · Python · SQL

This guide explores using DuckDB's Full-Text Search (FTS) extension to query large email datasets.

It covers preprocessing with Python and the usage of BM25 parameters, such as k1 and b, to tune ranking. While less feature-complete than Elasticsearch or Postgres, DuckDB provides an efficient, accessible solution for exploratory data analysis.

Design and implementation of DuckDB internals

duckdb.org · 10 Apr

Database · SQL · Education

Torsten Grust provides comprehensive course materials on the internal architecture of DuckDB.

The 'DiDi' course, designed for undergraduate students at the University of Tübingen, covers 15 weeks of topics including memory management, vectorized query execution, indexing with ART, and query optimization, providing a deep dive into the kernel of the DuckDB relational database system.

A DuckDB-based metabase alternative

github.com · 18 Feb

Database · SQL · Open Source

Shaper is an open-source, SQL-driven business intelligence tool powered by DuckDB.

It allows developers to build analytics dashboards through SQL, supporting Git-based workflows and AI-ready features. Users can embed white-labeled analytics using JS and React SDKs, automate reports, and connect to multiple data sources. It is self-hostable via Docker and licensed under MPL 2.0.

How TimescaleDB compresses time-series data

roszigit.com · 15 Jun

Database · PostgreSQL · SQL

TimescaleDB utilizes the hypercore engine, a hybrid row-columnar storage system, to achieve up to 98% compression on time-series data.

By grouping rows into batches and using specialized algorithms like delta encoding, Gorilla XOR, and run-length encoding, it outperforms native PostgreSQL TOAST mechanisms for IoT and financial datasets while simultaneously improving analytical query performance.

I imported the full Linux kernel git history into pgit

oseifert.ch · 5 Apr

Git · PostgreSQL · SQL

The author successfully imported the entire 20-year history of the Linux kernel into pgit, storing 1.4 million commits in a PostgreSQL database using delta compression.

This setup enables rapid, complex SQL querying of the entire history, revealing deep technical insights, development trends, and contributor patterns that would be labor-intensive to produce using standard Git tools.

Modern SQLite: Features You Didn't Know It Had

slicker.me · 2 Apr

Database · SQL · SQLite

Modern SQLite provides powerful features like native JSON support, FTS5 for full-text search, window functions for analytics, and STRICT tables for schema enforcement.

With generated columns, Write-Ahead Logging (WAL) for concurrency, and CTEs, SQLite has evolved into a robust, high-performance database suitable for complex applications without sacrificing its characteristic simplicity and reliability.

Good CTE, Bad CTE

boringsql.com · 29 Mar

Database · PostgreSQL · SQL

CTEs in PostgreSQL have evolved from 'optimization fences' into an efficient tool.

Since PostgreSQL 12, the planner automatically inlines most CTEs unless they are recursive, have side effects, or are referenced multiple times. While materialization can be useful for performance or atomicity, it often hides statistics from the query planner, occasionally leading to inefficient execution plans.

Ducks in a Column

duckdb.org · 10 Nov

Data Science · Database · Performance · SQL

DuckDB’s columnar storage enables efficient analytical queries by reading only required columns and processing values in vectors.

It can query local or remote CSV and Parquet files in place, exploit partitioning and statistics, and provide concise SQL with `COLUMNS`, `GROUP BY ALL`, `FILTER`, `PIVOT`, window functions, `QUALIFY`, and `ASOF JOIN`. The post also recommends writing sorted, compressed, narrowly typed Parquet and using `EXPLAIN ANALYZE` to verify scan pruning and column selection.

Looking Forward to Postgres 19: It's About Time

pgedge.com · 12 Jun

Database · PostgreSQL · SQL

Postgres 19 introduces native support for temporal tables, implementing SQL:2011 standards.

Using the WITHOUT OVERLAPS clause and FOR PORTION OF syntax, developers can now manage valid-time periods efficiently. This native approach replaces complex workarounds like GiST index exclusion constraints, simplifies data integrity for overlapping ranges, and introduces support for temporal foreign keys, significantly improving how Postgres handles time-sensitive data.

Is your Postgres migration safe or not safe?

safenotsafe.dev · 26 Sept

CLI · Database · SQL

safe-not-safe is an offline tool for checking PostgreSQL migrations, using libpg_query compiled to WASM in a browser worker and offering a CLI.

In the shown empty-file run, it finds no statements and flags none. The interface says telemetry is disabled and links to GitHub.

Statistics that live in your SQL

kolistat.com · 22 Jun

Data Science · Database · SQL

the-stats-duck v0.6.0, an open-source DuckDB extension, enables advanced statistical analysis directly within SQL.

New features include meta() for data profiling, lm() for linear regression, bootstrap() for resampling, expanded plotting capabilities, and ten new statistical distributions. Performance for reading SAS, SPSS, and Stata files is significantly improved, offering a powerful, portable statistics engine.

PgQue: Zero-Bloat Postgres Queue

github.com · 13 Apr

Database · PostgreSQL · SQL

PgQue is a zero-bloat, SQL-first event queue for PostgreSQL 14+.

By using snapshot-based batching and TRUNCATE-based rotation instead of row-level deletions, it avoids index bloat and VACUUM pressure. It supports event-driven fan-out, works on managed providers without extensions or sidecars, and offers an ACID-compliant alternative to traditional task queues like RabbitMQ.

I Don’t Want a Lesson in Computer Science!

duckdb.org · 25 Nov

Data Science · Database · SQL

Claude and DuckDB recreated a Star Trek: The Next Generation “Enterprise computer” by translating crew dialogue into SQL over a synthetic database modeled on ship records.

Using 11 scenes and the actual scripts, the system produced answers matching 40 of 49 dialogue results. Examples include detecting forged Stargazer logs, counting “Darmok” entries, narrowing substances through predicates, and correlating medical cases with visits. The downloadable enterprise_computer.duckdb database can be attached from the web and queried directly or used with Claude Code.

How JetBrains Built Cross-Database Queries into DataGrip with DuckDB

duckdb.org · 5 Nov

Database · Software Architecture · SQL

JetBrains embedded DuckDB in DataGrip to enable cross-database queries without building its own query engine.

DuckDB’s custom table functions connect its execution to DataGrip’s existing database functionality, allowing users to join PostgreSQL, MySQL, MongoDB, and other supported sources in one query without extra infrastructure. DataGrip exposes DuckDB’s SQL dialect and supports it as a first-class dialect. The initial implementation will evolve toward broader optimizations and file-based sources.

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