Skip to content

tsm_system_time

TABLESAMPLE method which accepts time in milliseconds as a limit

tsm_system_time · TABLESAMPLE method which accepts time in milliseconds as a limit

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4890tsm_system_timetsm_system_time1.0FUNCPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-dtrNoYesNoYesyesyes

Packages

PG19PG18PG17PG16PG15
1.01.01.01.01.0
This contrib extension ships with PostgreSQL.

Install

Create this extension with:

CREATE EXTENSION tsm_system_time;

Usage

tsm_system_time: time-based TABLESAMPLE method

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.

Table reader