RefLib

Reference library for AI

Back

postgresql_16:9.6.47.1 Examples

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

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

CREATE EXTENSION tsm_system_time;

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

This command will return as large a sample of my_table as it can read in 1 second (1000 milliseconds). Of course, if the whole table can be read in under 1 second, all its rows will be returned.

Back