Skip to content

Commit 3995ba9

Browse files
Add support for 'ONLY' in Index creation dialog. #6386
1 parent 4bb6b72 commit 3995ba9

9 files changed

Lines changed: 40 additions & 16 deletions

File tree

-32.5 KB
Loading
37.8 KB
Loading

docs/en_US/images/index_sql.png

46.4 KB
Loading

docs/en_US/images/index_with.png

75.3 KB
Loading

docs/en_US/index_dialog.rst

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ Use the fields in the *Definition* tab to define the index:
5151
* Use the drop-down listbox next to *Depends on extensions* to select the extension
5252
that this index depends on (for example, edbspl). If set, dropping the extension
5353
will automatically drop the index as well.
54+
* Move the switch next to *Only Table?* to the *Yes* position to create the index
55+
only on the parent table without recursing to its partitions. This button will be
56+
enabled for partition tables only. The default is *No*.
57+
* Move the switch next to *Unique?* to the *Yes* position to check for duplicate values
58+
in the table when the index is created and when data is added. The default is *No*.
59+
* Move the switch next to *NULLs not distinct?* to the *Yes* position to treat null values as not distinct.
60+
The default is *No*. This option is available only on PostgreSQL 15 and above.
61+
* Move the *Clustered?* switch to the *Yes* position to instruct the server to
62+
cluster the table.
63+
* Move the *Concurrent build?* switch to the *Yes* position to build the index
64+
without taking any locks that prevent concurrent inserts, updates, or deletes
65+
on the table.
66+
* Use the *Constraint* field to provide a constraint expression; a constraint
67+
expression limits the entries in the index to those rows that satisfy the
68+
constraint.
69+
70+
Click the *With* tab to continue.
71+
72+
.. image:: images/index_with.png
73+
:alt: Index dialog with tab
74+
:align: center
75+
5476
* Use the *Fill Factor* field to specify a fill factor for the index. The fill
5577
factor specifies how full the selected method will try to fill each index
5678
page.
@@ -66,18 +88,6 @@ Use the fields in the *Definition* tab to define the index:
6688
The default is *Yes*.
6789
* Move the switch next to *Autosummarize* to the *Yes* position to define whether a summarization run is
6890
queued for the previous page range whenever an insertion is detected on the next one. The default is *No*
69-
* Move the switch next to *Unique?* to the *Yes* position to check for duplicate values
70-
in the table when the index is created and when data is added. The default is *No*.
71-
* Move the switch next to *NULLs not distinct?* to the *Yes* position to treat null values as not distinct.
72-
The default is *No*. This option is available only on PostgreSQL 15 and above.
73-
* Move the *Clustered?* switch to the *Yes* position to instruct the server to
74-
cluster the table.
75-
* Move the *Concurrent build?* switch to the *Yes* position to build the index
76-
without taking any locks that prevent concurrent inserts, updates, or deletes
77-
on the table.
78-
* Use the *Constraint* field to provide a constraint expression; a constraint
79-
expression limits the entries in the index to those rows that satisfy the
80-
constraint.
8191

8292
Click the *Columns* tab to continue.
8393

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ export default class IndexSchema extends BaseUISchema {
364364
amname: undefined,
365365
fastupdate: false,
366366
autosummarize: false,
367+
indisonly: false,
367368
columns: [],
368369
...initValues
369370
});
@@ -522,7 +523,20 @@ export default class IndexSchema extends BaseUISchema {
522523
mode: ['create', 'edit', 'properties']
523524
},
524525
{
525-
type: 'nested-fieldset', label: gettext('With'), group: gettext('Definition'),
526+
id: 'indisonly', label: gettext('Only Table?'),
527+
type: 'switch', group: gettext('Definition'),
528+
disabled: () => {
529+
// ONLY is only applicable to partitioned tables
530+
// Disable if not a partitioned table or if viewing in schema (view mode)
531+
return inSchema(indexSchemaObj.node_info) ||
532+
!indexSchemaObj.node_info?.table?.is_partitioned;
533+
},
534+
mode: ['create'],
535+
min_version: 110000,
536+
helpMessage: gettext('When enabled, the index will only be created on this table, not on its partitions.'),
537+
},
538+
{
539+
type: 'nested-fieldset', label: gettext('With'), group: gettext('With'),
526540
schema: this.withSchema,
527541
},{
528542
id: 'indisunique', label: gettext('Unique?'), cell: 'string',

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/11_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE{% if data.indisunique %} UNIQUE{% endif %} INDEX{% if add_not_exists_clause %} IF NOT EXISTS{% endif %}{% if data.isconcurrent %} CONCURRENTLY{% endif %}{% if data.name %} {{conn|qtIdent(data.name)}}{% endif %}
22

3-
ON {{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
3+
ON {% if data.indisonly %}ONLY {% endif %}{{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
44

55
{% if mode == 'create' %}
66
({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{% if c.is_exp %}({{c.colname}}){% else %}{{conn|qtIdent(c.colname)}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/13_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE{% if data.indisunique %} UNIQUE{% endif %} INDEX{% if add_not_exists_clause %} IF NOT EXISTS{% endif %}{% if data.isconcurrent %} CONCURRENTLY{% endif %}{% if data.name %} {{conn|qtIdent(data.name)}}{% endif %}
22

3-
ON {{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
3+
ON {% if data.indisonly %}ONLY {% endif %}{{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
44

55
{% if mode == 'create' %}
66
({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{% if c.is_exp %}({{c.colname}}){% else %}{{conn|qtIdent(c.colname)}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/15_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE{% if data.indisunique %} UNIQUE{% endif %} INDEX{% if add_not_exists_clause %} IF NOT EXISTS{% endif %}{% if data.isconcurrent %} CONCURRENTLY{% endif %}{% if data.name %} {{conn|qtIdent(data.name)}}{% endif %}
22

3-
ON {{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
3+
ON {% if data.indisonly %}ONLY {% endif %}{{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
44

55
{% if mode == 'create' %}
66
({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{% if c.is_exp %}({{c.colname}}){% else %}{{conn|qtIdent(c.colname)}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}

0 commit comments

Comments
 (0)