Quick onboard
Deployment
Data Modeling
Connecting
Migration
Query
Operations and Maintenance
Common Maintenance
Partition
Backup and Restore
Expansion
Mirroring
Resource Management
Security
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool guide
Data type
Storage Engine
Executor
Stream
DR (Disaster Recovery)
Configuration
Index
Extension
SQL Reference
mars3_default_brin is a key feature of the MARS3 storage engine. It provides default BRIN index support at the table level. This allows automatic data filtering during sequential scans (SeqScan) without requiring manual index creation.
Enable mars3_default_brin by specifying the default_brinkeys parameter in the table definition:
CREATE TABLE t
(c1 BIGINT, c2 BIGINT, c3 BIGINT)
USING mars3
WITH (mars3options='default_brinkeys=30');
This parameter takes an integer value (default is 30):
0: Disables default BRIN indexing.-1: Automatically creates default BRIN indexes on all columns that support the <, >, and = operators.N: Automatically creates default BRIN indexes on the first N columns that support the <, >, and = operators.Use the mars3_brinkeys function to check which columns in a table have BRIN keys.
t using the MARS3 storage engine with three BIGINT columns: c1, c2, and c3. Set default_brinkeys=2 to automatically create BRIN indexes on the first two columns.CREATE TABLE t
(c1 BIGINT, c2 BIGINT, c3 BIGINT)
USING mars3
WITH (mars3options='default_brinkeys=2');
t. Use the generate_series function to generate values from 1 to 1,000,000 and insert them as rows.INSERT INTO t SELECT i,i,i FROM generate_series(1,1000000) AS i;
VACUUM on table t. For MARS3 tables, this moves row-store data into the columnar layer and builds internal BRIN structures.VACUUM t;
t where c1 is less than 1000.default_brinkeys=2, c1 (one of the first two columns) has an automatically created mars3_default_brin index. The query uses this index to accelerate execution.SELECT COUNT(*) FROM t WHERE c1 < 1000;
t where c3 is less than 1000.default_brinkeys=2, c3 (the third column) does not have an automatically created mars3_default_brin index. This query may not use any index and will likely perform slower than the previous one.SELECT COUNT(*) FROM t WHERE c3 < 1000;
mars3_brinmars3_brin |
mars3_default_brin |
|
|---|---|---|
| Creation | Requires manual CREATE INDEX |
Created automatically; no manual action needed |
| Scan support | Filters data only during IndexScan | Filters data during both IndexScan and SeqScan |
| Technology version | BRIN v2 | BRIN v2 |
| Parameterized queries | Supports parametric IndexScan | Supports parametric SeqScan |