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: src/current/v25.2/alter-index.md
+58Lines changed: 58 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,7 @@ Subcommand | Description |
38
38
[`CONFIGURE ZONE`](#configure-zone) | [Replication Controls]({% link {{ page.version.version }}/configure-replication-zones.md %}) for an index. |
39
39
[`PARTITION BY`](#partition-by) | Partition, re-partition, or un-partition an index.
40
40
[`RENAME TO`](#rename-to) | Change the name of an index.
41
+
[`SCATTER`](#scatter) | Redistribute leaseholders for the ranges of a table or index. |
41
42
[`SPLIT AT`](#split-at) | Force a [range split]({% link {{ page.version.version }}/architecture/distribution-layer.md %}#range-splits) at the specified row in the index.
42
43
[`UNSPLIT AT`](#unsplit-at) | Remove a range split enforcement in the index.
43
44
[`VISIBILITY`](#visibility) | Set the visibility of an index between a range of `0.0` and `1.0`.
@@ -119,6 +120,30 @@ The user must have the `CREATE` [privilege]({% link {{ page.version.version }}/s
119
120
120
121
For usage, see [Synopsis](#synopsis).
121
122
123
+
### `SCATTER`
124
+
125
+
`ALTER INDEX ... SCATTER` runs a specified set of ranges for a table or index through the [replication layer]({% link {{ page.version.version }}/architecture/replication-layer.md %}) queue. If many ranges have been created recently, the replication queue may transfer some leases to other replicas to balance load across the cluster. Some leaseholders may not update as a result of this command.
126
+
127
+
{{site.data.alerts.callout_info}}
128
+
`SCATTER` has the potential to result in data movement proportional to the size of the table or index being scattered, thus taking additional time and resources to complete.
129
+
{{site.data.alerts.end}}
130
+
131
+
For examples, see [Scatter indexes](#scatter-indexes).
132
+
133
+
#### Required privileges
134
+
135
+
The user must have the `INSERT`[privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table or index.
136
+
137
+
#### Parameters
138
+
139
+
Parameter | Description
140
+
----------|-------------
141
+
`table_name` | The name of the table that you want to scatter.
142
+
`table_index_name` | The name of the index that you want to scatter.
143
+
`expr_list` | A list of [scalar expressions]({% link {{ page.version.version }}/scalar-expressions.md %}) in the form of the primary key of the table or the specified index.
144
+
145
+
For usage, see [Synopsis](#synopsis).
146
+
122
147
### `SPLIT AT`
123
148
124
149
`ALTER INDEX ... SPLIT AT` forces a [range split]({% link {{ page.version.version }}/architecture/distribution-layer.md %}#range-splits) at a specified row in the index.
@@ -343,6 +368,39 @@ SHOW INDEXES FROM users;
343
368
(8 rows)
344
369
~~~
345
370
371
+
### Scatter indexes
372
+
373
+
Before scattering, you can view the current leaseholder distribution for an index:
374
+
375
+
{% include_cached copy-clipboard.html %}
376
+
~~~sql
377
+
WITH range_details AS (SHOW RANGES FROM DATABASE movr WITH DETAILS) SELECT range_id, lease_holder, replicas from range_details;
378
+
~~~
379
+
380
+
~~~
381
+
range_id | lease_holder | replicas
382
+
-----------+--------------+-----------
383
+
94 | 1 | {1}
384
+
~~~
385
+
386
+
{% include_cached copy-clipboard.html %}
387
+
~~~sql
388
+
> ALTER INDEX rides@revenue_idx SCATTER;
389
+
~~~
390
+
391
+
After scattering, recheck the leaseholder distribution:
392
+
393
+
{% include_cached copy-clipboard.html %}
394
+
~~~sql
395
+
WITH range_details AS (SHOW RANGES FROM DATABASE movr WITH DETAILS) SELECT range_id, lease_holder, replicas from range_details;
396
+
~~~
397
+
398
+
~~~
399
+
range_id | lease_holder | replicas
400
+
-----------+--------------+-----------
401
+
94 | 1 | {1}
402
+
~~~
403
+
346
404
### Split and unsplit indexes
347
405
348
406
{% include {{ page.version.version }}/sql/movr-statements-geo-partitioned-replicas.md %}
Copy file name to clipboardExpand all lines: src/current/v25.2/alter-table.md
+76Lines changed: 76 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,7 @@ Subcommand | Description | Can combine with other subcommands?
65
65
[`SET {storage parameter}`](#set-storage-parameter) | Set a storage parameter on a table. | Yes
66
66
[`SET LOCALITY`](#set-locality) | Set the table locality for a table in a [multi-region database]({% link {{ page.version.version }}/multiregion-overview.md %}). | No
67
67
[`SET SCHEMA`](#set-schema) | Change the [schema]({% link {{ page.version.version }}/sql-name-resolution.md %}) of a table. | No
68
+
[`SCATTER`](#scatter) | Redistribute leaseholders for the ranges of a table or index. | No
68
69
[`SPLIT AT`](#split-at) | Force a [range split]({% link {{ page.version.version }}/architecture/distribution-layer.md %}#range-splits) at the specified row in the table. | No
69
70
[`UNSPLIT AT`](#unsplit-at) | Remove a range split enforcement in the table. | No
70
71
[`VALIDATE CONSTRAINT`](#validate-constraint) | Check whether values in a column match a [constraint]({% link {{ page.version.version }}/constraints.md %}) on the column. | Yes
@@ -602,6 +603,30 @@ Parameter | Description |
602
603
603
604
For usage, see [Synopsis](#synopsis).
604
605
606
+
### `SCATTER`
607
+
608
+
`ALTER TABLE ... SCATTER` runs a specified set of ranges for a table or index through the [replication layer]({% link {{ page.version.version }}/architecture/replication-layer.md %}) queue. If many ranges have been created recently, the replication queue may transfer some leases to other replicas to balance load across the cluster. Some leaseholders may not update as a result of this command.
609
+
610
+
{{site.data.alerts.callout_info}}
611
+
`SCATTER` has the potential to result in data movement proportional to the size of the table or index being scattered, thus taking additional time and resources to complete.
612
+
{{site.data.alerts.end}}
613
+
614
+
For examples, see [Scatter tables](#scatter-tables).
615
+
616
+
#### Required privileges
617
+
618
+
The user must have the `INSERT`[privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table or index.
619
+
620
+
#### Parameters
621
+
622
+
Parameter | Description
623
+
----------|-------------
624
+
`table_name` | The name of the table that you want to scatter.
625
+
`table_index_name` | The name of the index that you want to scatter.
626
+
`expr_list` | A list of [scalar expressions]({% link {{ page.version.version }}/scalar-expressions.md %}) in the form of the primary key of the table or the specified index.
627
+
628
+
For usage, see [Synopsis](#synopsis).
629
+
605
630
### `SPLIT AT`
606
631
607
632
`ALTER TABLE ... SPLIT AT` forces a [range split]({% link {{ page.version.version }}/architecture/distribution-layer.md %}#range-splits) at a specified row in the table.
@@ -2827,6 +2852,57 @@ Then, change the table's schema:
2827
2852
(6 rows)
2828
2853
~~~
2829
2854
2855
+
### Scatter tables
2856
+
2857
+
Before scattering, you can view the current leaseholder distribution for a table:
2858
+
2859
+
{% include_cached copy-clipboard.html %}
2860
+
~~~ sql
2861
+
WITH range_details AS (SHOW RANGES FROM TABLE movr.users WITH DETAILS) SELECT range_id, lease_holder, replicas from range_details;
2862
+
~~~
2863
+
2864
+
~~~
2865
+
range_id | lease_holder | replicas
2866
+
-----------+--------------+-----------
2867
+
99 | 1 | {1}
2868
+
82 | 1 | {1}
2869
+
81 | 1 | {1}
2870
+
77 | 1 | {1}
2871
+
80 | 1 | {1}
2872
+
75 | 1 | {1}
2873
+
79 | 1 | {1}
2874
+
76 | 1 | {1}
2875
+
78 | 1 | {1}
2876
+
(9 rows)
2877
+
~~~
2878
+
2879
+
{% include_cached copy-clipboard.html %}
2880
+
~~~ sql
2881
+
ALTER TABLE movr.users SCATTER;
2882
+
~~~
2883
+
2884
+
After scattering, recheck the leaseholder distribution:
2885
+
2886
+
{% include_cached copy-clipboard.html %}
2887
+
~~~ sql
2888
+
WITH range_details AS (SHOW RANGES FROM TABLE movr.users WITH DETAILS) SELECT range_id, lease_holder, replicas from range_details;
2889
+
~~~
2890
+
2891
+
~~~
2892
+
range_id | lease_holder | replicas
2893
+
-----------+--------------+-----------
2894
+
99 | 1 | {1}
2895
+
82 | 1 | {1}
2896
+
81 | 1 | {1}
2897
+
77 | 1 | {1}
2898
+
80 | 1 | {1}
2899
+
75 | 1 | {1}
2900
+
79 | 1 | {1}
2901
+
76 | 1 | {1}
2902
+
78 | 1 | {1}
2903
+
(9 rows)
2904
+
~~~
2905
+
2830
2906
### Split and unsplit tables
2831
2907
2832
2908
{% include {{page.version.version}}/sql/movr-statements-geo-partitioned-replicas.md %}
0 commit comments