Skip to content

Commit

Permalink
1) Added support for SYSTEM, CONCURRENTLY and TABLESPACE options in R…
Browse files Browse the repository at this point in the history
…EINDEX. #6381

2) Added new/missing options to the VACUUM command. #6397
3) Added SKIP_LOCKED and BUFFER_USAGE_LIMIT option to Analyze command. #6415
  • Loading branch information
akshay-joshi authored Jul 27, 2023
1 parent e177344 commit a460644
Show file tree
Hide file tree
Showing 21 changed files with 1,334 additions and 179 deletions.
Binary file removed docs/en_US/images/maintenance.png
Binary file not shown.
Binary file added docs/en_US/images/maintenance_analyze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/maintenance_cluster.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/maintenance_reindex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/maintenance_vacuum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 83 additions & 10 deletions docs/en_US/maintenance_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,109 @@
Use the *Maintenance* dialog to VACUUM, ANALYZE, REINDEX or CLUSTER a database
or selected database objects.

.. image:: images/maintenance.png
:alt: Maintenance dialog
:align: center

While this utility is useful for ad-hoc maintenance purposes, you are encouraged
to perform automatic VACUUM jobs on a regular schedule.

Select a button next to *Maintenance operation* to specify the type of
maintenance:

.. image:: images/maintenance_vacuum.png
:alt: Maintenance dialog
:align: center

* Click *VACUUM* to scan the selected database or table to reclaim storage used
by dead tuples.

* Move the *FULL* switch to the *Yes* position to compact tables by writing
a completely new version of the table file without dead space. The default
is *No*.
a completely new version of the table file without dead space.

* Move the *FREEZE* switch to the *Yes* position to freeze data in a table
when it will have no further updates. The default is *No*.
when it will have no further updates.

* Move the *ANALYZE* switch to the *Yes* position to issue ANALYZE commands
whenever the content of a table has changed sufficiently. The default is
*No*.
whenever the content of a table has changed sufficiently.

* Move the *DISABLE PAGE SKIPPING* switch to the *Yes* position to disables
all page-skipping behavior.

* Move the *SKIP LOCKED* switch to the *Yes* position to specifies that
VACUUM should not wait for any conflicting locks to be released when
beginning work on a relation. This option is available from v12 onwards.

* Move the *TRUNCATE* switch to the *Yes* position to specifies that VACUUM
should attempt to truncate off any empty pages at the end of the table and
allow the disk space for the truncated pages to be returned to the operating
system. This option is available from v12 onwards.

* Move the *PROCESS TOAST* switch to the *Yes* position to specifies that
VACUUM should attempt to process the corresponding TOAST table for each
relation, if one exists. This option is available from v14 onwards.

* Move the *PROCESS MAIN* switch to the *Yes* position to specifies that
VACUUM should attempt to process the main relation. This option is available
from v16 onwards.

* Move the *SKIP DATABASE STATS* switch to the *Yes* position to specifies
that VACUUM should skip updating the database-wide statistics about oldest
unfrozen XIDs. This option is available from v16 onwards.

* Move the *ONLY DATABASE STATS* switch to the *Yes* position to specifies
that VACUUM should do nothing except update the database-wide statistics
about oldest unfrozen XIDs . This option is available from v16 onwards.

* Use the *INDEX CLEANUP* field to force VACUUM to process indexes when there
are more than zero dead tuples.

* Use the *PARALLEL* field to specify index vacuum and index cleanup phases
of VACUUM in parallel using integer background workers. This option is
available from v13 onwards.

* Use the *BUFFER USAGE LIMIT* field to specifies the Buffer Access Strategy
ring buffer size for VACUUM. This size is used to calculate the number of
shared buffers which will be reused as part of this strategy. This option
is available from v16 onwards


.. image:: images/maintenance_analyze.png
:alt: Maintenance dialog
:align: center

* Click *ANALYZE* to update the stored statistics used by the query planner.
This enables the query optimizer to select the fastest query plan for optimal
performance.

* Move the *SKIP LOCKED* switch to the *Yes* position to specifies that
ANALYZE should not wait for any conflicting locks to be released when
beginning work on a relation. This option is available from v12 onwards.

* Use the *BUFFER USAGE LIMIT* field to specifies the Buffer Access Strategy
ring buffer size for ANALYZE. This size is used to calculate the number of
shared buffers which will be reused as part of this strategy. This option
is available from v16 onwards

.. image:: images/maintenance_reindex.png
:alt: Maintenance dialog
:align: center

* Click *REINDEX* to rebuild any index in case it has degenerated due to the
insertion of unusual data patterns. This happens, for example, if you insert
rows with increasing index values, and delete low index values.

* Move the *SYSTEM* switch to the *Yes* position to recreate all indexes
on system catalogs within the current database. This option is enabled
only when database object is selected.

* Move the *CONCURRENTLY* switch to the *Yes* position to rebuild the index
without taking any locks that prevent concurrent inserts, updates, or
deletes on the table. This option is available from v12 onwards.

* Use the *TABLESPACE* field to specifies that indexes will be rebuilt on
a new tablespace. This option is available from v14 onwards.

.. image:: images/maintenance_cluster.png
:alt: Maintenance dialog
:align: center

* Click *CLUSTER* to instruct PostgreSQL to cluster the selected table.

To exclude status messages from the process output, move the *Verbose Messages*
Expand All @@ -47,4 +120,4 @@ to exit the dialog without performing maintenance operations, click *Cancel*.

pgAdmin will run the maintenance process in background. You can view all the background
process with there running status and logs on the :ref:`Processes <processes>`
tab
tab.
1 change: 1 addition & 0 deletions docs/en_US/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ notes for it.
.. toctree::
:maxdepth: 1

release_notes_7_6
release_notes_7_5
release_notes_7_4
release_notes_7_3
Expand Down
32 changes: 32 additions & 0 deletions docs/en_US/release_notes_7_6.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
***********
Version 7.6
***********

Release date: 2023-08-24

This release contains a number of bug fixes and new features since the release of pgAdmin 4 v7.5.

Supported Database Servers
**************************
**PostgreSQL**: 11, 12, 13, 14 and 15

**EDB Advanced Server**: 11, 12, 13, 14 and 15

Bundled PostgreSQL Utilities
****************************
**psql**, **pg_dump**, **pg_dumpall**, **pg_restore**: 15.3


New features
************

| `Issue #6381 <https://github.com/pgadmin-org/pgadmin4/issues/6381>`_ - Added support for SYSTEM, CONCURRENTLY and TABLESPACE options in REINDEX.
| `Issue #6397 <https://github.com/pgadmin-org/pgadmin4/issues/6397>`_ - Added new/missing options to the VACUUM command.
| `Issue #6415 <https://github.com/pgadmin-org/pgadmin4/issues/6415>`_ - Added SKIP_LOCKED and BUFFER_USAGE_LIMIT option to Analyze command.
Housekeeping
************


Bug fixes
*********
6 changes: 3 additions & 3 deletions web/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,19 +470,19 @@
##########################################################################
DEFAULT_BINARY_PATHS = {
"pg": "",
"pg-10": "",
"pg-11": "",
"pg-12": "",
"pg-13": "",
"pg-14": "",
"pg-15": "",
"pg-16": "",
"ppas": "",
"ppas-10": "",
"ppas-11": "",
"ppas-12": "",
"ppas-13": "",
"ppas-14": "",
"ppas-15": ""
"ppas-15": "",
"ppas-16": ""
}

##########################################################################
Expand Down
75 changes: 33 additions & 42 deletions web/pgadmin/tools/maintenance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,59 +75,50 @@ def get_server_name(self):

return "{0} ({1}:{2})".format(s.name, host, port)

def get_op(self):
op = self._check_for_vacuum()
def get_object_msg(self):
msg = _("on database '{0}'").format(self.data['database'])
if 'primary_key' in self.data or 'unique_constraint' in self.data:
msg = _("on constraint '{0}/{1}/{2}/{3}'").format(
self.data['database'], self.data['schema'], self.data['table'],
self.data['primary_key'] if 'primary_key' in self.data else
self.data['unique_constraint'])
elif 'index' in self.data:
msg = _("on index '{0}/{1}/{2}/{3}'").format(
self.data['database'], self.data['schema'],
self.data['table'], self.data['index'])
elif 'table' in self.data:
msg = _("on table '{0}/{1}/{2}'").format(
self.data['database'], self.data['schema'], self.data['table'])
elif 'schema' in self.data:
msg = _("on schema '{0}/{1}'").format(self.data['database'],
self.data['schema'])
return msg

@property
def message(self):
op = _('VACUUM')
if self.data['op'] == "ANALYZE":
op = _('ANALYZE')
if self.data['verbose']:
op += '(' + _('VERBOSE') + ')'

if self.data['op'] == "REINDEX":
if 'schema' in self.data and self.data['schema']:
if 'primary_key' in self.data or \
'unique_constraint' in self.data or \
'index' in self.data:
return _('REINDEX INDEX')
else:
return _('REINDEX TABLE')
elif self.data['op'] == "REINDEX" and 'schema' not in self.data:
op = _('REINDEX')

if self.data['op'] == "CLUSTER":
elif self.data['op'] == "REINDEX" and 'schema' in self.data:
if 'primary_key' in self.data or 'unique_constraint' in self.data\
or 'index' in self.data:
op = _('REINDEX INDEX')
elif 'table' in self.data:
op = _('REINDEX TABLE')
else:
op = _('REINDEX SCHEMA')
elif self.data['op'] == "CLUSTER":
op = _('CLUSTER')

return op

@property
def message(self):
res = _("{0} on database '{1}' of server {2}")
return res.format(
self.get_op(), self.data['database'], self.get_server_name())
res = _("{0} {1} of server {2}")
return res.format(op, self.get_object_msg(), self.get_server_name())

@property
def type_desc(self):
return _("Maintenance")

def _check_for_vacuum(self):
"""
Check for VACUUM in data and return format response.
:return: response.
"""
res = None
if self.data['op'] == "VACUUM":
res = _('VACUUM ({0})')

opts = []
if 'vacuum_full' in self.data and self.data['vacuum_full']:
opts.append(_('FULL'))
if 'vacuum_freeze' in self.data and self.data['vacuum_freeze']:
opts.append(_('FREEZE'))
if self.data['verbose']:
opts.append(_('VERBOSE'))

res = res.format(', '.join(str(x) for x in opts))
return res

def details(self, cmd, args):
return {
"message": self.message,
Expand Down
22 changes: 19 additions & 3 deletions web/pgadmin/tools/maintenance/static/js/maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Notify from '../../../../static/js/helpers/Notifier';
import {getUtilityView} from '../../../../browser/static/js/utility_view';
import getApiInstance from 'sources/api_instance';
import MaintenanceSchema, {getVacuumSchema} from './maintenance.ui';
import { getNodeListByName } from '../../../../browser/static/js/node_ajax';

define([
'sources/gettext', 'sources/url_for', 'sources/pgadmin', 'pgadmin.browser',
Expand Down Expand Up @@ -76,9 +77,15 @@ define([
},
getUISchema: function(treeItem) {
let treeNodeInfo = pgBrowser.tree.getTreeNodeHierarchy(treeItem);
const selectedNode = pgBrowser.tree.selected();
let itemNodeData = pgBrowser.tree.findNodeByDomElement(selectedNode).getData();

return new MaintenanceSchema(
()=>getVacuumSchema(),
()=>getVacuumSchema({
tablespace: ()=>getNodeListByName('tablespace', treeNodeInfo, itemNodeData, {}, (m)=>{
return (m.label != 'pg_global');
})
}),
{
nodeInfo: treeNodeInfo
}
Expand Down Expand Up @@ -106,6 +113,15 @@ define([
if(treeInfo?.mview) {
extraData['table'] = treeInfo?.mview._label;
}
if(treeInfo?.primary_key) {
extraData['primary_key'] = treeInfo?.primary_key._label;
}
if(treeInfo?.unique_constraint) {
extraData['unique_constraint'] = treeInfo?.unique_constraint._label;
}
if(treeInfo?.index) {
extraData['index'] = treeInfo?.index._label;
}
extraData['save_btn_icon'] = 'done';
return extraData;
},
Expand Down Expand Up @@ -174,7 +190,7 @@ define([
} else{

pgBrowser.Node.registerUtilityPanel();
let panel = pgBrowser.Node.addUtilityPanel(pgBrowser.stdW.md),
let panel = pgBrowser.Node.addUtilityPanel(pgBrowser.stdW.md, pgBrowser.stdH.lg),
j = panel.$container.find('.obj_properties').first();

let schema = that.getUISchema(item);
Expand All @@ -194,7 +210,7 @@ define([
});

getUtilityView(
schema, treeInfo, 'select', 'dialog', j[0], panel, that.saveCallBack, extraData, 'OK', jobUrl, sqlHelpUrl, helpUrl);
schema, treeInfo, 'create', 'dialog', j[0], panel, that.saveCallBack, extraData, 'OK', jobUrl, sqlHelpUrl, helpUrl);
}
})
.catch(function() {
Expand Down
Loading

0 comments on commit a460644

Please sign in to comment.