tsm_system_rows

tsm_system_rows

tsm_system_rows : TABLESAMPLE method which accepts number of rows as a limit

Overview

ID Extension Package Version Category License Language
4910
tsm_system_rows
tsm_system_rows
1.0
FUNC
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-dt-
No
Yes
No
Yes
no
yes
Relationships
Need By
documentdb
See Also
random
permuteseq
tsm_system_time
pg_crash
pg_idkit
pgx_ulid
pg_uuidv7
pg_hashids

Packages

PG18 PG17 PG16 PG15 PG14
1.0
1.0
1.0
1.0
1.0

This is a built-in contrib extension ship with the PostgreSQL kernel

Install

Create this extension with:

CREATE EXTENSION tsm_system_rows;

Usage

tsm_system_rows: row-count-based TABLESAMPLE method

Provides the SYSTEM_ROWS table sampling method that returns exactly the specified number of rows.

CREATE EXTENSION tsm_system_rows;

TABLESAMPLE Method

SYSTEM_ROWS(count int) – maximum number of rows to return.

Examples

-- Sample exactly 100 rows
SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);

-- Quick peek at 10 rows from a large table
SELECT * FROM large_table TABLESAMPLE SYSTEM_ROWS(10);

Performs block-level sampling (may exhibit clustering effects with small samples). Returns all rows if the table has fewer rows than requested. Does not support REPEATABLE.

Last updated on