|
| 1 | +\c spqr-console |
| 2 | + |
| 3 | + SPQR router admin console |
| 4 | + Here you can configure your routing rules |
| 5 | +------------------------------------------------ |
| 6 | + You can find documentation here |
| 7 | +https://github.com/pg-sharding/spqr/tree/master/docs |
| 8 | + |
| 9 | +CREATE DISTRIBUTION ds1 COLUMN TYPES integer; |
| 10 | + add distribution |
| 11 | +------------------------ |
| 12 | + distribution id -> ds1 |
| 13 | +(1 row) |
| 14 | + |
| 15 | +CREATE KEY RANGE kridi1 from 0 route to sh1 FOR DISTRIBUTION ds1; |
| 16 | + add key range |
| 17 | +--------------- |
| 18 | + bound -> 0 |
| 19 | +(1 row) |
| 20 | + |
| 21 | +CREATE KEY RANGE kridi2 from 11 route to sh2 FOR DISTRIBUTION ds1; |
| 22 | + add key range |
| 23 | +--------------- |
| 24 | + bound -> 11 |
| 25 | +(1 row) |
| 26 | + |
| 27 | +ALTER DISTRIBUTION ds1 ATTACH RELATION tlt1 DISTRIBUTION KEY i; |
| 28 | + attach table |
| 29 | +------------------------- |
| 30 | + relation name -> tlt1 |
| 31 | + distribution id -> ds1 |
| 32 | +(2 rows) |
| 33 | + |
| 34 | +\c regress |
| 35 | +CREATE SCHEMA sh2; |
| 36 | +NOTICE: send query to shard(s) : sh1,sh2,sh3,sh4 |
| 37 | +CREATE TABLE sh2.tlt1(i int, j int); |
| 38 | +NOTICE: send query to shard(s) : sh1,sh2,sh3,sh4 |
| 39 | +INSERT INTO sh2.tlt1 (i, j) VALUES(1, 12); |
| 40 | +NOTICE: send query to shard(s) : sh1 |
| 41 | +INSERT INTO sh2.tlt1 (i, j) VALUES(1, 12); |
| 42 | +NOTICE: send query to shard(s) : sh1 |
| 43 | +INSERT INTO sh2.tlt1 (i, j) VALUES(2, 13); |
| 44 | +NOTICE: send query to shard(s) : sh1 |
| 45 | +INSERT INTO sh2.tlt1 (i, j) VALUES(2, 13); |
| 46 | +NOTICE: send query to shard(s) : sh1 |
| 47 | +INSERT INTO sh2.tlt1 (i, j) VALUES(12, 12); |
| 48 | +NOTICE: send query to shard(s) : sh2 |
| 49 | +INSERT INTO sh2.tlt1 (i, j) VALUES(12, 14); |
| 50 | +NOTICE: send query to shard(s) : sh2 |
| 51 | +INSERT INTO sh2.tlt1 (i, j) VALUES(122, 124); |
| 52 | +NOTICE: send query to shard(s) : sh2 |
| 53 | +INSERT INTO sh2.tlt1 (i, j) VALUES(112, 124); |
| 54 | +NOTICE: send query to shard(s) : sh2 |
| 55 | +INSERT INTO sh2.tlt1 (i, j) VALUES(113, 125); |
| 56 | +NOTICE: send query to shard(s) : sh2 |
| 57 | +select (select sum(j) from sh2.tlt1 where i = 112); |
| 58 | +NOTICE: send query to shard(s) : sh2 |
| 59 | + sum |
| 60 | +----- |
| 61 | + 124 |
| 62 | +(1 row) |
| 63 | + |
| 64 | +select (select sum(j) from sh2.tlt1 where i = 112), (select sum(j) from sh2.tlt1 where sh2.tlt1.i = 113); |
| 65 | +NOTICE: send query to shard(s) : sh2 |
| 66 | + sum | sum |
| 67 | +-----+----- |
| 68 | + 124 | 125 |
| 69 | +(1 row) |
| 70 | + |
| 71 | +select coalesce((select sum(j) from sh2.tlt1 where i = 1), 0), coalesce((select sum(j) from sh2.tlt1 where i = 2 and j not in (select 12)), 0); |
| 72 | +NOTICE: send query to shard(s) : sh1 |
| 73 | + coalesce | coalesce |
| 74 | +----------+---------- |
| 75 | + 24 | 26 |
| 76 | +(1 row) |
| 77 | + |
| 78 | +DROP SCHEMA sh2 CASCADE; |
| 79 | +NOTICE: send query to shard(s) : sh1,sh2,sh3,sh4 |
| 80 | +\c spqr-console |
| 81 | + |
| 82 | + SPQR router admin console |
| 83 | + Here you can configure your routing rules |
| 84 | +------------------------------------------------ |
| 85 | + You can find documentation here |
| 86 | +https://github.com/pg-sharding/spqr/tree/master/docs |
| 87 | + |
| 88 | +DROP DISTRIBUTION ALL CASCADE; |
| 89 | + drop distribution |
| 90 | +------------------------ |
| 91 | + distribution id -> ds1 |
| 92 | +(1 row) |
| 93 | + |
| 94 | +DROP KEY RANGE ALL; |
| 95 | + drop key range |
| 96 | +---------------- |
| 97 | +(0 rows) |
| 98 | + |
0 commit comments