leapfrog
leapfrog · Ordered intersection of B-tree indexes through a PostgreSQL planner hook
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102271 | leapfrog | leapfrog | 0.0.5 | FEAT | PostgreSQL | C |
PostgreSQL · 18
Usage
Sources:
leapfrog 0.0.5 is an experimental PostgreSQL 18 planner extension. It combines ordinary B-tree indexes into an ordered intersection, allowing suitable filtered queries with ordering and a limit to use fewer specialized indexes. Other PostgreSQL majors are unsupported.
Enable and Inspect
Install the SQL helpers as a superuser and load the library in the session that plans queries:
The planner may choose Custom Scan (Index Merge Intersect) when its estimated cost is favorable. An empty demonstration table normally keeps a native plan. The outer index ends with the sort column; leading index columns must have equality conditions. Each additional index must contribute an independent equality or partial-index predicate.
Loading and Settings
CREATE EXTENSION registers the SQL helpers; every subsequent session still needs to load the library. LOAD 'leapfrog' applies to the current session. An administrator can configure session_preload_libraries for new sessions, or shared_preload_libraries for all backends, with a server restart for the latter.
| Setting | Default | Purpose |
|---|---|---|
leapfrog.enabled | on | Offer the custom path |
leapfrog.force | off | Prefer eligible custom paths for diagnostics |
leapfrog.max_indexes | 4 | Maximum streams per intersection, from 2 to 16 |
leapfrog.min_indexes | 2 | Developer control for minimum stream count |
leapfrog.skip_after | 64 | Initial skip-ahead threshold; 0 disables skipping |
leapfrog.force can select slower plans. Use actual query plans and timings before changing defaults. The normal planner retains its other paths.
Limits and Maintenance
Sort keys can use types with a B-tree operator family and can contain nulls. Each index stream must supply the requested order, collation and null placement. Both ascending and descending nbtree v4 indexes are supported. Ranges, lists and expression index columns are unsupported for the equality prefix.
Duplicate-key TID groups are bounded by work_mem; an overflowing group falls back to row-condition checks. Open scans can hold index pages pinned and delay vacuum. This extension creates no application tables and does not replace existing indexes.
DROP EXTENSION does not unload a library already loaded into a backend. Disable its planner contribution with SET leapfrog.enabled = off, and reconnect sessions after replacing the library. Use a proper installation or package replacement; overwriting a loaded shared-library file in place can crash its users.