|
| 1 | +-- Check partitioned tables. |
| 2 | +\c spqr-console |
| 3 | + |
| 4 | + SPQR router admin console |
| 5 | + Here you can configure your routing rules |
| 6 | +------------------------------------------------ |
| 7 | + You can find documentation here |
| 8 | +https://github.com/pg-sharding/spqr/tree/master/docs |
| 9 | + |
| 10 | +-- SETUP |
| 11 | +CREATE DISTRIBUTION ds1 COLUMN TYPES varchar hash; |
| 12 | + add distribution |
| 13 | +------------------------ |
| 14 | + distribution id -> ds1 |
| 15 | +(1 row) |
| 16 | + |
| 17 | +CREATE KEY RANGE krid1 FROM 0 ROUTE TO sh1 FOR DISTRIBUTION ds1; |
| 18 | + add key range |
| 19 | +--------------- |
| 20 | + bound -> 0 |
| 21 | +(1 row) |
| 22 | + |
| 23 | +CREATE KEY RANGE krid2 FROM 2147483648 ROUTE TO sh2 FOR DISTRIBUTION ds1; |
| 24 | + add key range |
| 25 | +--------------------- |
| 26 | + bound -> 2147483648 |
| 27 | +(1 row) |
| 28 | + |
| 29 | +-- the set of all unsigned 32-bit integers (0 to 4294967295) |
| 30 | +ALTER DISTRIBUTION ds1 ATTACH RELATION xxhash_part DISTRIBUTION KEY i HASH FUNCTION MURMUR; |
| 31 | + attach table |
| 32 | +-------------------------------- |
| 33 | + relation name -> xxhash_part |
| 34 | + distribution id -> ds1 |
| 35 | +(2 rows) |
| 36 | + |
| 37 | +\c regress |
| 38 | +CREATE TABLE xxhash_part (i uuid, d date) partition by range (d); |
| 39 | +NOTICE: send query to shard(s) : sh1,sh2 |
| 40 | +create table xxhash_part_1 partition of xxhash_part for values from ('2024-12-01') to ('2024-12-31'); |
| 41 | +NOTICE: send query to shard(s) : sh1,sh2 |
| 42 | +create table xxhash_part_2 partition of xxhash_part for values from ('2024-11-01') to ('2024-11-30'); |
| 43 | +NOTICE: send query to shard(s) : sh1,sh2 |
| 44 | +create table xxhash_part_3 partition of xxhash_part for values from ('2024-10-01') to ('2024-10-31'); |
| 45 | +NOTICE: send query to shard(s) : sh1,sh2 |
| 46 | +insert into xxhash_part (i,d ) values ('b37da10c-25a0-4473-96fd-c3871bd81d00', '2024-12-23'); |
| 47 | +NOTICE: send query to shard(s) : sh2 |
| 48 | +insert into xxhash_part (i,d ) values ('b1569ed9-4029-495f-8d7c-02b216528c0a', '2024-12-21'); |
| 49 | +NOTICE: send query to shard(s) : sh1 |
| 50 | +insert into xxhash_part (i,d ) values ('0583484b-e407-41e3-9c75-66c1994944c8', '2024-12-20'); |
| 51 | +NOTICE: send query to shard(s) : sh2 |
| 52 | +insert into xxhash_part (i,d ) values ('b14f8871-ba67-4244-8fa6-45edabaf6206', '2024-12-22'); |
| 53 | +NOTICE: send query to shard(s) : sh1 |
| 54 | +insert into xxhash_part (i,d ) values ('7906fd75-60ae-4e1d-99c5-da19d4b63515', '2024-11-23'); |
| 55 | +NOTICE: send query to shard(s) : sh2 |
| 56 | +insert into xxhash_part (i,d ) values ('99d75dea-c62c-4bb3-9d6e-eda36432bda0', '2024-11-21'); |
| 57 | +NOTICE: send query to shard(s) : sh2 |
| 58 | +insert into xxhash_part (i,d ) values ('0bd49f01-b01f-4c18-bd44-d75746a7c71c', '2024-11-20'); |
| 59 | +NOTICE: send query to shard(s) : sh2 |
| 60 | +insert into xxhash_part (i,d ) values ('3dcd025f-b016-4d1c-aaa8-4f8462f9aa8e', '2024-11-22'); |
| 61 | +NOTICE: send query to shard(s) : sh1 |
| 62 | +insert into xxhash_part (i,d ) values ('93043bc0-b6d3-4bb6-b1b4-869d2b4a4967', '2024-10-23'); |
| 63 | +NOTICE: send query to shard(s) : sh1 |
| 64 | +insert into xxhash_part (i,d ) values ('f6a01c78-9ce8-4cc3-a78f-32bebc4ccb4a', '2024-10-21'); |
| 65 | +NOTICE: send query to shard(s) : sh1 |
| 66 | +insert into xxhash_part (i,d ) values ('b3e31fad-80fa-48df-bcc0-51ffd1594df3', '2024-10-20'); |
| 67 | +NOTICE: send query to shard(s) : sh2 |
| 68 | +insert into xxhash_part (i,d ) values ('d15707df-f256-49a5-a693-3feda5afe678', '2024-10-22'); |
| 69 | +NOTICE: send query to shard(s) : sh2 |
| 70 | +SELECT * FROM xxhash_part ORDER BY d /* __spqr__execute_on: sh1 */; |
| 71 | +NOTICE: send query to shard(s) : sh1 |
| 72 | + i | d |
| 73 | +--------------------------------------+------------ |
| 74 | + f6a01c78-9ce8-4cc3-a78f-32bebc4ccb4a | 2024-10-21 |
| 75 | + 93043bc0-b6d3-4bb6-b1b4-869d2b4a4967 | 2024-10-23 |
| 76 | + 3dcd025f-b016-4d1c-aaa8-4f8462f9aa8e | 2024-11-22 |
| 77 | + b1569ed9-4029-495f-8d7c-02b216528c0a | 2024-12-21 |
| 78 | + b14f8871-ba67-4244-8fa6-45edabaf6206 | 2024-12-22 |
| 79 | +(5 rows) |
| 80 | + |
| 81 | +SELECT * FROM xxhash_part ORDER BY d /* __spqr__execute_on: sh2 */; |
| 82 | +NOTICE: send query to shard(s) : sh2 |
| 83 | + i | d |
| 84 | +--------------------------------------+------------ |
| 85 | + b3e31fad-80fa-48df-bcc0-51ffd1594df3 | 2024-10-20 |
| 86 | + d15707df-f256-49a5-a693-3feda5afe678 | 2024-10-22 |
| 87 | + 0bd49f01-b01f-4c18-bd44-d75746a7c71c | 2024-11-20 |
| 88 | + 99d75dea-c62c-4bb3-9d6e-eda36432bda0 | 2024-11-21 |
| 89 | + 7906fd75-60ae-4e1d-99c5-da19d4b63515 | 2024-11-23 |
| 90 | + 0583484b-e407-41e3-9c75-66c1994944c8 | 2024-12-20 |
| 91 | + b37da10c-25a0-4473-96fd-c3871bd81d00 | 2024-12-23 |
| 92 | +(7 rows) |
| 93 | + |
| 94 | +--TEARDOWN |
| 95 | +DROP TABLE xxhash_part; |
| 96 | +NOTICE: send query to shard(s) : sh1,sh2 |
| 97 | +\c spqr-console |
| 98 | + |
| 99 | + SPQR router admin console |
| 100 | + Here you can configure your routing rules |
| 101 | +------------------------------------------------ |
| 102 | + You can find documentation here |
| 103 | +https://github.com/pg-sharding/spqr/tree/master/docs |
| 104 | + |
| 105 | +DROP DISTRIBUTION ALL CASCADE; |
| 106 | + drop distribution |
| 107 | +------------------------ |
| 108 | + distribution id -> ds1 |
| 109 | +(1 row) |
| 110 | + |
| 111 | +DROP KEY RANGE ALL; |
| 112 | + drop key range |
| 113 | +---------------- |
| 114 | +(0 rows) |
| 115 | + |
0 commit comments