Staggered September and October intervals share an October-first boundary guide; filled starting endpoints and open ending endpoints show lower-inclusive, upper-exclusive ownership.

Table partitioning splits data by range or key

Range partitioning turns a boundary definition into a write-routing rule. PostgreSQL places a row in the partition whose bounds accept its key, whether the row arrives on time or months late. Correct boundaries, compatible timestamp types, and a plan for missing ranges matter before any query can benefit from pruning. ...

February 10, 2028 · 5 min · XB Field Notes
The same four scores produce positions 1,2,3,4, ranks 1,2,2,4 and dense ranks 1,2,2,3.

Window functions rank rows without collapsing groups

Ranking functions attach a position to each input row within a partition. They do not collapse a team, department, or customer into one aggregate row. The important choice is what a tie means: a unique position, a shared competition rank with gaps, or a shared rank counting distinct score groups. ...

February 8, 2028 · 5 min · XB Field Notes
Correlated LEFT JOIN LATERAL selects orders 12 and 11 for customer 1, order 20 for customer 2, and a NULL-extended row for customer 3.

LATERAL lets each row open its own subquery

LATERAL lets a FROM item refer to columns from preceding items. It is useful when each parent needs a small, differently parameterized result, such as its two newest orders. The query remains one SQL statement and one database round trip, while the lateral expression states which outer values determine each result. It does not promise one particular physical execution strategy. ...

January 19, 2028 · 5 min · XB Field Notes
One logical parent branches to two physical month partitions, with a separate rightward row-movement arrow below the children.

Partitioning splits one table into many pieces that look like one

Declarative partitioning lets PostgreSQL expose one logical table while storing its rows in separate partitions. The parent routes writes and provides a common query target; the physical partitions hold the data. Its strongest benefits often concern lifecycle management and selective access, but the choice also affects keys, query shape, and operational locking. ...

December 23, 2027 · 5 min · XB Field Notes
Eligible SELECT CTEs can fold into their parent or form a shared materialized result. A modifying CTE passes rows through RETURNING.

A Common Table Expression names a query you can reuse

A common table expression gives a query result a name within one SQL statement. It can make a complex report readable by naming populations and intermediate calculations before the final SELECT. That name is not a persistent table, and it does not by itself promise a cached result, a particular scan count, or a sequence of procedural steps. ...

December 19, 2027 · 5 min · XB Field Notes
A value arrow enters a percent-s placeholder in SQL. A separate purple loop marks optional reuse; zero named statements can still retain binding. Source fixture, not rerun.

Prepared statements separate values from SQL structure

Parameter binding gives a database value a designated position in a SQL statement. A name containing a quote or a semicolon remains a value instead of becoming another clause. Reusing a named prepared statement adds a separate optimization: the server can retain statement information across executions in one session. Safe binding does not require the application to create a named statement for every query. ...

October 16, 2027 · 5 min · XB Field Notes
For a=7 and b=7, actual output is 100 rows. Independence predicts one row, while collected dependency statistics predict 100. For a=7 and b=8, the dependency still predicts 100 while actual output is zero.

Query planners bet on cost, not certainty

A query planner chooses an execution path using estimated work. It does not run every candidate, time them, and keep the winner. PostgreSQL compares possible scans, joins, sorts, and other operations using statistics and a cost model. The chosen plan is therefore a prediction under current assumptions. Understanding a wrong prediction requires identifying which assumption failed, rather than treating a sequential scan or a nested loop as inherently suspicious. ...

September 17, 2027 · 4 min · XB Field Notes
Within a tenant-first B-tree, time values are sorted inside each tenant group. The predicate tenant equals two and happened between 100 and 120 selects the contiguous values 102, 106, 110, 114 and 118 from tenant two only.

Composite indexes match multi-column queries

A composite B-tree index orders tuples by its first key, then by the next key within each first-key group. This structure can make a tenant-specific time range cheap to locate. The useful rule is about how much index space a predicate narrows, not a prohibition against mentioning later columns or writing WHERE conditions in a different textual order. ...

September 15, 2027 · 5 min · XB Field Notes