VastbaseG100

基于openGauss内核开发的企业级关系型数据库。

Menu

SAMPLE抽样采集语法

1. 创建测试数据
CREATE TABLE test_sample (id int, name text) WITH (fillfactor=10);
INSERT INTO test_sample
  SELECT i, repeat(i::text, 200) FROM generate_series(0, 9) s(i);
2. sample采样测试
SELECT t.id FROM test_sample AS t SAMPLE BLOCK (50) SEED (0);
SELECT id FROM test_sample SAMPLE BLOCK (100.0/11) SEED (0);
SELECT id FROM test_sample SAMPLE BLOCK (50) SEED (0);
SELECT id FROM test_sample SAMPLE (50) SEED (0);
SELECT id FROM test_sample SAMPLE (5.5) SEED (0);
SELECT count(*) FROM test_sample SAMPLE BLOCK (100);
SELECT count(*) FROM test_sample SAMPLE BLOCK (100) SEED (1+2);
SELECT count(*) FROM test_sample SAMPLE BLOCK (100) SEED (0.4);