partition_hash_test_setup.sql 983 B

1234567891011121314151617181920212223242526
  1. DROP TABLE IF EXISTS shards CASCADE;
  2. CREATE TABLE shards (
  3. id BIGINT,
  4. value VARCHAR
  5. ) PARTITION BY HASH (id);
  6. -- DROP TABLE IF EXISTS shard_0;
  7. CREATE TABLE shard_0 PARTITION OF shards FOR VALUES WITH (MODULUS 5, REMAINDER 0);
  8. -- DROP TABLE IF EXISTS shard_1;
  9. CREATE TABLE shard_1 PARTITION OF shards FOR VALUES WITH (MODULUS 5, REMAINDER 1);
  10. -- DROP TABLE IF EXISTS shard_2;
  11. CREATE TABLE shard_2 PARTITION OF shards FOR VALUES WITH (MODULUS 5, REMAINDER 2);
  12. -- DROP TABLE IF EXISTS shard_3;
  13. CREATE TABLE shard_3 PARTITION OF shards FOR VALUES WITH (MODULUS 5, REMAINDER 3);
  14. -- DROP TABLE IF EXISTS shard_4;
  15. CREATE TABLE shard_4 PARTITION OF shards FOR VALUES WITH (MODULUS 5, REMAINDER 4);
  16. INSERT INTO shards SELECT generate_series(1, 500), 'value';
  17. SELECT * FROM shard_0 ORDER BY id LIMIT 10;
  18. SELECT * FROM shard_1 ORDER BY id LIMIT 10;
  19. SELECT * FROM shard_2 ORDER BY id LIMIT 10;
  20. SELECT * FROM shard_3 ORDER BY id LIMIT 10;
  21. SELECT * FROM shard_4 ORDER BY id LIMIT 10;