tsm_system_time
TABLESAMPLE method which accepts time in milliseconds as a limit
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
tsm_system_time | 1.0 | FUNC | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4890 | tsm_system_time | No | Yes | No | Yes | Yes | No | - |
| Related | random permuteseq tsm_system_rows pg_crash pg_idkit pgx_ulid pg_uuidv7 pg_hashids |
|---|
Version
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
Install
Note: This is a built-in contrib extension of PostgreSQL
CREATE EXTENSION tsm_system_time;
Usage
Provides the SYSTEM_TIME table sampling method that returns as many rows as can be read within a specified time limit.
CREATE EXTENSION tsm_system_time;
TABLESAMPLE Method
SYSTEM_TIME(milliseconds float) – maximum time to spend reading the table.
Examples
-- Sample rows readable within 1 second
SELECT * FROM my_table TABLESAMPLE SYSTEM_TIME(1000);
-- Sample from a large table with a 500ms budget
SELECT count(*) FROM large_table TABLESAMPLE SYSTEM_TIME(500);
Performs block-level sampling (not row-level). If the entire table can be read within the time limit, all rows are returned. Does not support REPEATABLE.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.