You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -297,7 +297,13 @@ export const cluster = new Cluster({
297
297
298
298
### MicroshardingDebugViews
299
299
300
-
The`microsharding_migration_after()`function creates so-called "debug views" for each sharded table in your cluster. For instance, it you have `sh0001.users`, `sh0002.users` etc. tables. then it will create a debug view `public.users` with the definition like:
300
+
The`microsharding_migration_after()`function creates so-called "debug views" for each sharded table in your cluster:
For instance, it you have `sh0001.users`, `sh0002.users` etc. tables, then it will create a debug view `public.users` with the definition like:
301
307
302
308
```sql
303
309
-- This is what pg-microsharding creates automatically.
@@ -309,9 +315,13 @@ CREATE VIEW public.users AS
309
315
...;
310
316
```
311
317
312
-
Even more, if you pass the list of all PostgreSQL hosts, and those hosts can access each other without a password (e.g. theyhave`/var/lib/postgresql/N/.pgpass`files), then those debug views will work **across all shards on all nodes, including the remote ones** (using [foreign-data wrapper](https://www.postgresql.org/docs/current/postgres-fdw.html) functionality).
318
+
Even more, if you pass the list of all PostgreSQL hosts, and those hosts can access each other without a password (e.g. they have `/var/lib/postgresql/N/.pgpass` files), then those debug views will work **across all shards on all nodes, including the remote ones** (using [foreign-data wrapper](https://www.postgresql.org/docs/current/postgres-fdw.html) functionality):
313
319
314
-
So **for debugging purposes**, you'll be able to run queries across all microshards in your `psql` sessions. This is typically very convenient.
So **for debugging purposes**, you'll be able to run queries _across all microshards on all hosts_ in your `psql` sessions.
315
325
316
326
Of course those **debug views are not suitable for production traffic**: cross-node communication in PostgreSQL, as well as query planning, work not enough inefficiently. Do not even try, use application-level microshards routing, like e.g. [Ent Framework](https://ent-framework.org/) provides.
317
327
@@ -324,6 +334,12 @@ postgres=# SELECT shard, email FROM users
324
334
-- debugging purposes only.
325
335
```
326
336
327
-
As of `microsharding_migration_before()`, you must call it before any changes are applied to your microsharded tables. The function drops all of the debug views mentioned above. E.g. if you remove a column from a table, PostgreSQL would not allow you to do it it this column is mentioned in any of the views, so it's important to drop the views and re-create them afterwards.
337
+
As of `microsharding_migration_before()`, you must call it before any changes are applied to your microsharded tables:
The function drops all of the debug views mentioned above. E.g. if you remove a column from a table, PostgreSQL would not allow you to do it it this column is mentioned in any of the views, so it's important to drop the views and re-create them afterwards.
328
344
329
345
Typically, you just call `microsharding_migration_before()` in your pre-migration sequence and then call `microsharding_migration_after()` in your post-migration steps.
Copy file name to clipboardExpand all lines: docs/README.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -301,7 +301,13 @@ export const cluster = new Cluster({
301
301
302
302
### MicroshardingDebugViews
303
303
304
-
The`microsharding_migration_after()`function creates so-called "debug views" for each sharded table in your cluster. For instance, it you have `sh0001.users`, `sh0002.users` etc. tables. then it will create a debug view `public.users` with the definition like:
304
+
The`microsharding_migration_after()`function creates so-called "debug views" for each sharded table in your cluster:
For instance, it you have `sh0001.users`, `sh0002.users` etc. tables, then it will create a debug view `public.users` with the definition like:
305
311
306
312
```sql
307
313
-- This is what pg-microsharding creates automatically.
@@ -313,9 +319,13 @@ CREATE VIEW public.users AS
313
319
...;
314
320
```
315
321
316
-
Even more, if you pass the list of all PostgreSQL hosts, and those hosts can access each other without a password (e.g. theyhave`/var/lib/postgresql/N/.pgpass`files), then those debug views will work **across all shards on all nodes, including the remote ones** (using [foreign-data wrapper](https://www.postgresql.org/docs/current/postgres-fdw.html) functionality).
322
+
Even more, if you pass the list of all PostgreSQL hosts, and those hosts can access each other without a password (e.g. they have `/var/lib/postgresql/N/.pgpass` files), then those debug views will work **across all shards on all nodes, including the remote ones** (using [foreign-data wrapper](https://www.postgresql.org/docs/current/postgres-fdw.html) functionality):
317
323
318
-
So **for debugging purposes**, you'll be able to run queries across all microshards in your `psql` sessions. This is typically very convenient.
So **for debugging purposes**, you'll be able to run queries _across all microshards on all hosts_ in your `psql` sessions.
319
329
320
330
Of course those **debug views are not suitable for production traffic**: cross-node communication in PostgreSQL, as well as query planning, work not enough inefficiently. Do not even try, use application-level microshards routing, like e.g. [Ent Framework](https://ent-framework.org/) provides.
321
331
@@ -328,6 +338,12 @@ postgres=# SELECT shard, email FROM users
328
338
-- debugging purposes only.
329
339
```
330
340
331
-
As of `microsharding_migration_before()`, you must call it before any changes are applied to your microsharded tables. The function drops all of the debug views mentioned above. E.g. if you remove a column from a table, PostgreSQL would not allow you to do it it this column is mentioned in any of the views, so it's important to drop the views and re-create them afterwards.
341
+
As of `microsharding_migration_before()`, you must call it before any changes are applied to your microsharded tables:
The function drops all of the debug views mentioned above. E.g. if you remove a column from a table, PostgreSQL would not allow you to do it it this column is mentioned in any of the views, so it's important to drop the views and re-create them afterwards.
332
348
333
349
Typically, you just call `microsharding_migration_before()` in your pre-migration sequence and then call `microsharding_migration_after()` in your post-migration steps.
0 commit comments