RefLib

Reference library for AI

Back

postgresql_16:9.6.46.1 Examples

PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > tsm_system_rows — the SYSTEM_ROWS sampling method for TABLESAMPLE > Examples

Here is an example of selecting a sample of a table with SYSTEM_ROWS. First install the extension:

CREATE EXTENSION tsm_system_rows;

Then you can use it in a SELECT command, for instance: SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);

This command will return a sample of 100 rows from the table my_table (unless the table does not have 100 visible rows, in which case all its rows are returned).

Back