mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-16 10:30:26 +02:00
32 lines
946 B
Plaintext
32 lines
946 B
Plaintext
|
CREATE EXTENSION tsm_system_rows;
|
||
|
CREATE TABLE test_tablesample (id int, name text) WITH (fillfactor=10); -- force smaller pages so we don't have to load too much data to get multiple pages
|
||
|
INSERT INTO test_tablesample SELECT i, repeat(i::text, 1000) FROM generate_series(0, 30) s(i) ORDER BY i;
|
||
|
ANALYZE test_tablesample;
|
||
|
SELECT count(*) FROM test_tablesample TABLESAMPLE system_rows (1000);
|
||
|
count
|
||
|
-------
|
||
|
31
|
||
|
(1 row)
|
||
|
|
||
|
SELECT id FROM test_tablesample TABLESAMPLE system_rows (8) REPEATABLE (5432);
|
||
|
id
|
||
|
----
|
||
|
7
|
||
|
14
|
||
|
21
|
||
|
28
|
||
|
4
|
||
|
11
|
||
|
18
|
||
|
25
|
||
|
(8 rows)
|
||
|
|
||
|
EXPLAIN SELECT id FROM test_tablesample TABLESAMPLE system_rows (20) REPEATABLE (10);
|
||
|
QUERY PLAN
|
||
|
-----------------------------------------------------------------------------------
|
||
|
Sample Scan (system_rows) on test_tablesample (cost=0.00..80.20 rows=20 width=4)
|
||
|
(1 row)
|
||
|
|
||
|
-- done
|
||
|
DROP TABLE test_tablesample CASCADE;
|