mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix sorting of sizes on the statistics views by sorting raw values and prettifying on the client side. Includes Jasmine tests for the prettyfying function. Fixes #2315
This commit is contained in:
committed by
Dave Page
parent
c32bf7780e
commit
94b7fc483a
@@ -627,6 +627,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
canDropCascade: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Index size'],
|
||||
Init: function() {
|
||||
/* Avoid multiple registration of menus */
|
||||
if (this.initialized)
|
||||
|
||||
@@ -19,6 +19,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
hasSQL: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Index size'],
|
||||
parent_type: 'table',
|
||||
canDrop: true,
|
||||
canDropCascade: true,
|
||||
|
||||
@@ -12,7 +12,8 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
sqlAlterHelp: 'sql-alterindex.html',
|
||||
sqlCreateHelp: 'sql-createindex.html',
|
||||
columns: ['name', 'description'],
|
||||
hasStatistics: true
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size', 'Index size']
|
||||
});
|
||||
};
|
||||
|
||||
@@ -215,6 +216,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
hasSQL: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size', 'Index size'],
|
||||
Init: function() {
|
||||
/* Avoid mulitple registration of menus */
|
||||
if (this.initialized)
|
||||
|
||||
@@ -4,12 +4,12 @@ SELECT
|
||||
idx_tup_fetch AS {{ conn|qtIdent(_('Index tuples fetched')) }},
|
||||
idx_blks_read AS {{ conn|qtIdent(_('Index blocks read')) }},
|
||||
idx_blks_hit AS {{ conn|qtIdent(_('Index blocks hit')) }},
|
||||
pg_size_pretty(pg_relation_size({{ exid }}::OID)) AS {{ conn|qtIdent(_('Index size')) }}
|
||||
pg_relation_size({{ exid }}::OID) AS {{ conn|qtIdent(_('Index size')) }}
|
||||
{#=== Extended stats ===#}
|
||||
{% if is_pgstattuple %}
|
||||
,version AS {{ conn|qtIdent(_('Version')) }},
|
||||
tree_level AS {{ conn|qtIdent(_('Tree level')) }},
|
||||
pg_size_pretty(index_size) AS {{ conn|qtIdent(_('Index size')) }},
|
||||
index_size AS {{ conn|qtIdent(_('Index size')) }},
|
||||
root_block_no AS {{ conn|qtIdent(_('Root block no')) }},
|
||||
internal_pages AS {{ conn|qtIdent(_('Internal pages')) }},
|
||||
leaf_pages AS {{ conn|qtIdent(_('Leaf pages')) }},
|
||||
|
||||
@@ -3,7 +3,7 @@ SELECT
|
||||
idx_scan AS {{ conn|qtIdent(_('Index scans')) }},
|
||||
idx_tup_read AS {{ conn|qtIdent(_('Index tuples read')) }},
|
||||
idx_tup_fetch AS {{ conn|qtIdent(_('Index tuples fetched')) }},
|
||||
pg_size_pretty(pg_relation_size(indexrelid)) AS {{ conn|qtIdent(_('Size')) }}
|
||||
pg_relation_size(indexrelid) AS {{ conn|qtIdent(_('Size')) }}
|
||||
FROM
|
||||
pg_stat_all_indexes stat
|
||||
JOIN pg_class cls ON cls.oid=indexrelid
|
||||
|
||||
@@ -4,12 +4,12 @@ SELECT
|
||||
idx_tup_fetch AS {{ conn|qtIdent(_('Index tuples fetched')) }},
|
||||
idx_blks_read AS {{ conn|qtIdent(_('Index blocks read')) }},
|
||||
idx_blks_hit AS {{ conn|qtIdent(_('Index blocks hit')) }},
|
||||
pg_size_pretty(pg_relation_size({{ idx }}::OID)) AS {{ conn|qtIdent(_('Index size')) }}
|
||||
pg_relation_size({{ idx }}::OID) AS {{ conn|qtIdent(_('Index size')) }}
|
||||
{#=== Extended stats ===#}
|
||||
{% if is_pgstattuple %}
|
||||
,version AS {{ conn|qtIdent(_('Version')) }},
|
||||
tree_level AS {{ conn|qtIdent(_('Tree level')) }},
|
||||
pg_size_pretty(index_size) AS {{ conn|qtIdent(_('Index size')) }},
|
||||
index_size AS {{ conn|qtIdent(_('Index size')) }},
|
||||
root_block_no AS {{ conn|qtIdent(_('Root block no')) }},
|
||||
internal_pages AS {{ conn|qtIdent(_('Internal pages')) }},
|
||||
leaf_pages AS {{ conn|qtIdent(_('Leaf pages')) }},
|
||||
|
||||
@@ -4,12 +4,12 @@ SELECT
|
||||
idx_tup_fetch AS {{ conn|qtIdent(_('Index tuples fetched')) }},
|
||||
idx_blks_read AS {{ conn|qtIdent(_('Index blocks read')) }},
|
||||
idx_blks_hit AS {{ conn|qtIdent(_('Index blocks hit')) }},
|
||||
pg_size_pretty(pg_relation_size({{ cid }}::OID)) AS {{ conn|qtIdent(_('Index size')) }}
|
||||
pg_relation_size({{ cid }}::OID) AS {{ conn|qtIdent(_('Index size')) }}
|
||||
{#=== Extended stats ===#}
|
||||
{% if is_pgstattuple %}
|
||||
,version AS {{ conn|qtIdent(_('Version')) }},
|
||||
tree_level AS {{ conn|qtIdent(_('Tree level')) }},
|
||||
pg_size_pretty(index_size) AS {{ conn|qtIdent(_('Index size')) }},
|
||||
index_size AS {{ conn|qtIdent(_('Index size')) }},
|
||||
root_block_no AS {{ conn|qtIdent(_('Root block no')) }},
|
||||
internal_pages AS {{ conn|qtIdent(_('Internal pages')) }},
|
||||
leaf_pages AS {{ conn|qtIdent(_('Leaf pages')) }},
|
||||
|
||||
@@ -13,7 +13,10 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
label: '{{ _('Tables') }}',
|
||||
type: 'coll-table',
|
||||
columns: ['name', 'relowner', 'description'],
|
||||
hasStatistics: true
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
|
||||
'Toast table size', 'Tuple length',
|
||||
'Dead tuple length', 'Free space']
|
||||
});
|
||||
};
|
||||
|
||||
@@ -25,6 +28,9 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
hasSQL: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size', 'Indexes size', 'Table size',
|
||||
'Toast table size', 'Tuple length',
|
||||
'Dead tuple length', 'Free space'],
|
||||
sqlAlterHelp: 'sql-altertable.html',
|
||||
sqlCreateHelp: 'sql-createtable.html',
|
||||
dialogHelp: '{{ url_for('help.static', filename='table_dialog.html') }}',
|
||||
|
||||
@@ -14,12 +14,12 @@ SELECT
|
||||
autovacuum_count AS {{ conn|qtIdent(_('Autovacuum counter')) }},
|
||||
analyze_count AS {{ conn|qtIdent(_('Analyze counter')) }},
|
||||
autoanalyze_count AS {{ conn|qtIdent(_('Autoanalyze counter')) }},
|
||||
pg_size_pretty(pg_relation_size(st.relid)
|
||||
pg_relation_size(st.relid)
|
||||
+ CASE WHEN cl.reltoastrelid = 0 THEN 0 ELSE pg_relation_size(cl.reltoastrelid)
|
||||
+ COALESCE((SELECT SUM(pg_relation_size(indexrelid))
|
||||
FROM pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0) END
|
||||
+ COALESCE((SELECT SUM(pg_relation_size(indexrelid))
|
||||
FROM pg_index WHERE indrelid=st.relid)::int8, 0)) AS {{ conn|qtIdent(_('Size')) }}
|
||||
FROM pg_index WHERE indrelid=st.relid)::int8, 0) AS {{ conn|qtIdent(_('Size')) }}
|
||||
FROM
|
||||
pg_stat_all_tables st
|
||||
JOIN
|
||||
|
||||
@@ -25,23 +25,23 @@ SELECT
|
||||
autovacuum_count AS {{ conn|qtIdent(_('Autovacuum counter')) }},
|
||||
analyze_count AS {{ conn|qtIdent(_('Analyze counter')) }},
|
||||
autoanalyze_count AS {{ conn|qtIdent(_('Autoanalyze counter')) }},
|
||||
pg_size_pretty(pg_relation_size(stat.relid)) AS {{ conn|qtIdent(_('Table size')) }},
|
||||
CASE WHEN cl.reltoastrelid = 0 THEN NULL ELSE pg_size_pretty(pg_relation_size(cl.reltoastrelid)
|
||||
pg_relation_size(stat.relid) AS {{ conn|qtIdent(_('Table size')) }},
|
||||
CASE WHEN cl.reltoastrelid = 0 THEN NULL ELSE pg_relation_size(cl.reltoastrelid)
|
||||
+ COALESCE((SELECT SUM(pg_relation_size(indexrelid))
|
||||
FROM pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0))
|
||||
FROM pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0)
|
||||
END AS {{ conn|qtIdent(_('Toast table size')) }},
|
||||
pg_size_pretty(COALESCE((SELECT SUM(pg_relation_size(indexrelid))
|
||||
FROM pg_index WHERE indrelid=stat.relid)::int8, 0))
|
||||
COALESCE((SELECT SUM(pg_relation_size(indexrelid))
|
||||
FROM pg_index WHERE indrelid=stat.relid)::int8, 0)
|
||||
AS {{ conn|qtIdent(_('Indexes size')) }}
|
||||
{% if is_pgstattuple %}
|
||||
{#== EXTENDED STATS ==#}
|
||||
,tuple_count AS {{ conn|qtIdent(_('Tuple count')) }},
|
||||
pg_size_pretty(tuple_len) AS {{ conn|qtIdent(_('Tuple length')) }},
|
||||
tuple_len AS {{ conn|qtIdent(_('Tuple length')) }},
|
||||
tuple_percent AS {{ conn|qtIdent(_('Tuple percent')) }},
|
||||
dead_tuple_count AS {{ conn|qtIdent(_('Dead tuple count')) }},
|
||||
pg_size_pretty(dead_tuple_len) AS {{ conn|qtIdent(_('Dead tuple length')) }},
|
||||
dead_tuple_len AS {{ conn|qtIdent(_('Dead tuple length')) }},
|
||||
dead_tuple_percent AS {{ conn|qtIdent(_('Dead tuple percent')) }},
|
||||
pg_size_pretty(free_space) AS {{ conn|qtIdent(_('Free space')) }},
|
||||
free_space AS {{ conn|qtIdent(_('Free space')) }},
|
||||
free_percent AS {{ conn|qtIdent(_('Free percent')) }}
|
||||
FROM
|
||||
pgstattuple('{{schema_name}}.{{table_name}}'), pg_stat_all_tables stat
|
||||
|
||||
@@ -12,7 +12,8 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
label: '{{ _('Databases') }}',
|
||||
type: 'coll-database',
|
||||
columns: ['name', 'datowner', 'comments'],
|
||||
hasStatistics: true
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size', 'Size of temporary files']
|
||||
});
|
||||
};
|
||||
|
||||
@@ -26,6 +27,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
hasSQL: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size', 'Size of temporary files'],
|
||||
canDrop: function(node) {
|
||||
return node.canDrop;
|
||||
},
|
||||
|
||||
@@ -17,11 +17,11 @@ SELECT
|
||||
slave.confl_bufferpin AS {{ conn|qtIdent(_('Bufferpin conflicts')) }},
|
||||
slave.confl_deadlock AS {{ conn|qtIdent(_('Deadlock conflicts')) }},
|
||||
temp_files AS {{ conn|qtIdent(_("Temporary files")) }},
|
||||
pg_size_pretty(temp_bytes) AS {{ conn|qtIdent(_("Size of temporary files")) }},
|
||||
temp_bytes AS {{ conn|qtIdent(_("Size of temporary files")) }},
|
||||
deadlocks AS {{ conn|qtIdent(_("Deadlocks")) }},
|
||||
blk_read_time AS {{ conn|qtIdent(_("Block read time")) }},
|
||||
blk_write_time AS {{ conn|qtIdent(_("Block write time")) }},
|
||||
pg_size_pretty(pg_database_size(db.datid)) AS {{ conn|qtIdent(_('Size')) }}
|
||||
pg_database_size(db.datid) AS {{ conn|qtIdent(_('Size')) }}
|
||||
FROM
|
||||
pg_stat_database db
|
||||
LEFT JOIN pg_stat_database_conflicts slave ON db.datid=slave.datid
|
||||
|
||||
@@ -16,7 +16,7 @@ SELECT
|
||||
slave.confl_snapshot AS {{ conn|qtIdent(_('Snapshot conflicts')) }},
|
||||
slave.confl_bufferpin AS {{ conn|qtIdent(_('Bufferpin conflicts')) }},
|
||||
slave.confl_deadlock AS {{ conn|qtIdent(_('Deadlock conflicts')) }},
|
||||
pg_size_pretty(pg_database_size(db.datid)) AS {{ conn|qtIdent(_('Size')) }}
|
||||
pg_database_size(db.datid) AS {{ conn|qtIdent(_('Size')) }}
|
||||
FROM
|
||||
pg_stat_database db
|
||||
LEFT JOIN pg_stat_database_conflicts slave ON db.datid=slave.datid
|
||||
|
||||
@@ -9,7 +9,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
label: '{{ _('Tablespaces') }}',
|
||||
type: 'coll-tablespace',
|
||||
columns: ['name', 'spcuser', 'description'],
|
||||
hasStatistics: true
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size']
|
||||
});
|
||||
};
|
||||
|
||||
@@ -25,6 +26,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
canDrop: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Size'],
|
||||
Init: function() {
|
||||
/* Avoid mulitple registration of menus */
|
||||
if (this.initialized)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{### SQL to fetch tablespace object stats ###}
|
||||
{% if tsid %}
|
||||
SELECT pg_size_pretty(pg_tablespace_size({{ tsid|qtLiteral }}::OID)) AS {{ conn|qtIdent(_('Size')) }}
|
||||
SELECT pg_tablespace_size({{ tsid|qtLiteral }}::OID) AS {{ conn|qtIdent(_('Size')) }}
|
||||
{% else %}
|
||||
SELECT ts.spcname AS {{ conn|qtIdent(_('Name')) }},
|
||||
pg_size_pretty(pg_tablespace_size(ts.oid)) AS {{ conn|qtIdent(_('Size')) }}
|
||||
pg_tablespace_size(ts.oid) AS {{ conn|qtIdent(_('Size')) }}
|
||||
FROM
|
||||
pg_catalog.pg_tablespace ts;
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user