mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 21:03:59 +00:00
Show table size fo MySQL and Postgres #552
This commit is contained in:
@@ -396,17 +396,17 @@
|
|||||||
functionName: 'tableReader',
|
functionName: 'tableReader',
|
||||||
},
|
},
|
||||||
hasPermission('dbops/model/edit') && {
|
hasPermission('dbops/model/edit') && {
|
||||||
label: _t('dbObject.dropCollection', { defaultMessage: 'Drop collection/container'}),
|
label: _t('dbObject.dropCollection', { defaultMessage: 'Drop collection/container' }),
|
||||||
isDropCollection: true,
|
isDropCollection: true,
|
||||||
requiresWriteAccess: true,
|
requiresWriteAccess: true,
|
||||||
},
|
},
|
||||||
hasPermission('dbops/table/rename') && {
|
hasPermission('dbops/table/rename') && {
|
||||||
label: _t('dbObject.renameCollection', { defaultMessage: 'Rename collection/container'}),
|
label: _t('dbObject.renameCollection', { defaultMessage: 'Rename collection/container' }),
|
||||||
isRenameCollection: true,
|
isRenameCollection: true,
|
||||||
requiresWriteAccess: true,
|
requiresWriteAccess: true,
|
||||||
},
|
},
|
||||||
hasPermission('dbops/table/backup') && {
|
hasPermission('dbops/table/backup') && {
|
||||||
label: _t('dbObject.createCollectionBackup', { defaultMessage: 'Create collection/container backup'}),
|
label: _t('dbObject.createCollectionBackup', { defaultMessage: 'Create collection/container backup' }),
|
||||||
isDuplicateCollection: true,
|
isDuplicateCollection: true,
|
||||||
requiresWriteAccess: true,
|
requiresWriteAccess: true,
|
||||||
},
|
},
|
||||||
@@ -590,7 +590,10 @@
|
|||||||
});
|
});
|
||||||
} else if (menu.isDropCollection) {
|
} else if (menu.isDropCollection) {
|
||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: _t('dbObject.confirmDropCollection', { defaultMessage: 'Really drop collection {name}?', values: { name: data.pureName } }),
|
message: _t('dbObject.confirmDropCollection', {
|
||||||
|
defaultMessage: 'Really drop collection {name}?',
|
||||||
|
values: { name: data.pureName },
|
||||||
|
}),
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
const dbid = _.pick(data, ['conid', 'database']);
|
const dbid = _.pick(data, ['conid', 'database']);
|
||||||
runOperationOnDatabase(dbid, {
|
runOperationOnDatabase(dbid, {
|
||||||
@@ -621,7 +624,10 @@
|
|||||||
const driver = await getDriver();
|
const driver = await getDriver();
|
||||||
|
|
||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: _t('dbObject.confirmCloneCollection', { defaultMessage: 'Really create collection/container copy named {name}?', values: { name: newName } }),
|
message: _t('dbObject.confirmCloneCollection', {
|
||||||
|
defaultMessage: 'Really create collection/container copy named {name}?',
|
||||||
|
values: { name: newName },
|
||||||
|
}),
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
const dbid = _.pick(data, ['conid', 'database']);
|
const dbid = _.pick(data, ['conid', 'database']);
|
||||||
runOperationOnDatabase(dbid, {
|
runOperationOnDatabase(dbid, {
|
||||||
@@ -721,9 +727,7 @@
|
|||||||
if (!item.submenu) {
|
if (!item.submenu) {
|
||||||
if (!item) return item;
|
if (!item) return item;
|
||||||
|
|
||||||
return {...item,
|
return { ...item, label: _tval(item.label) };
|
||||||
label: _tval(item.label)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
@@ -773,7 +777,9 @@
|
|||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
// title: getObjectTitle(connection, schemaName, pureName),
|
// title: getObjectTitle(connection, schemaName, pureName),
|
||||||
title: tabComponent ? getObjectTitle(connection, schemaName, pureName) : _t('dbObject.query', { defaultMessage: 'Query #' }),
|
title: tabComponent
|
||||||
|
? getObjectTitle(connection, schemaName, pureName)
|
||||||
|
: _t('dbObject.query', { defaultMessage: 'Query #' }),
|
||||||
focused: tabComponent == null,
|
focused: tabComponent == null,
|
||||||
tooltip,
|
tooltip,
|
||||||
icon:
|
icon:
|
||||||
@@ -1040,6 +1046,7 @@
|
|||||||
import { getSupportedScriptTemplates } from '../utility/applyScriptTemplate';
|
import { getSupportedScriptTemplates } from '../utility/applyScriptTemplate';
|
||||||
import { getBoolSettingsValue, getOpenDetailOnArrowsSettings } from '../settings/settingsTools';
|
import { getBoolSettingsValue, getOpenDetailOnArrowsSettings } from '../settings/settingsTools';
|
||||||
import { isProApp } from '../utility/proTools';
|
import { isProApp } from '../utility/proTools';
|
||||||
|
import formatFileSize from '../utility/formatFileSize';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -1068,6 +1075,9 @@
|
|||||||
if (data.tableRowCount != null) {
|
if (data.tableRowCount != null) {
|
||||||
res.push(`${formatRowCount(data.tableRowCount)} rows`);
|
res.push(`${formatRowCount(data.tableRowCount)} rows`);
|
||||||
}
|
}
|
||||||
|
if (data.sizeBytes) {
|
||||||
|
res.push(formatFileSize(data.sizeBytes));
|
||||||
|
}
|
||||||
if (data.tableEngine) {
|
if (data.tableEngine) {
|
||||||
res.push(data.tableEngine);
|
res.push(data.tableEngine);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ select
|
|||||||
TABLE_NAME as pureName,
|
TABLE_NAME as pureName,
|
||||||
TABLE_TYPE as objectType,
|
TABLE_TYPE as objectType,
|
||||||
TABLE_ROWS as tableRowCount,
|
TABLE_ROWS as tableRowCount,
|
||||||
|
DATA_LENGTH + INDEX_LENGTH as sizeBytes,
|
||||||
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as modifyDate
|
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as modifyDate
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
where TABLE_SCHEMA = '#DATABASE#'
|
where TABLE_SCHEMA = '#DATABASE#'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ select
|
|||||||
TABLE_ROWS as tableRowCount,
|
TABLE_ROWS as tableRowCount,
|
||||||
ENGINE as tableEngine,
|
ENGINE as tableEngine,
|
||||||
TABLE_COMMENT as objectComment,
|
TABLE_COMMENT as objectComment,
|
||||||
|
DATA_LENGTH + INDEX_LENGTH as sizeBytes,
|
||||||
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as modifyDate
|
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as modifyDate
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
where TABLE_SCHEMA = '#DATABASE#' and (TABLE_TYPE='BASE TABLE' or TABLE_TYPE='SYSTEM VERSIONED') and TABLE_NAME =OBJECT_ID_CONDITION;
|
where TABLE_SCHEMA = '#DATABASE#' and (TABLE_TYPE='BASE TABLE' or TABLE_TYPE='SYSTEM VERSIONED') and TABLE_NAME =OBJECT_ID_CONDITION;
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
const newTable = {
|
const newTable = {
|
||||||
pureName: table.pure_name,
|
pureName: table.pure_name,
|
||||||
schemaName: table.schema_name,
|
schemaName: table.schema_name,
|
||||||
|
sizeBytes: table.size_bytes,
|
||||||
objectId: `tables:${table.schema_name}.${table.pure_name}`,
|
objectId: `tables:${table.schema_name}.${table.pure_name}`,
|
||||||
contentHash: table.hash_code_columns ? `${table.hash_code_columns}-${table.hash_code_constraints}` : null,
|
contentHash: table.hash_code_columns ? `${table.hash_code_columns}-${table.hash_code_constraints}` : null,
|
||||||
};
|
};
|
||||||
@@ -410,6 +411,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
objectId: `tables:${x.schema_name}.${x.pure_name}`,
|
objectId: `tables:${x.schema_name}.${x.pure_name}`,
|
||||||
pureName: x.pure_name,
|
pureName: x.pure_name,
|
||||||
schemaName: x.schema_name,
|
schemaName: x.schema_name,
|
||||||
|
sizeBytes: x.size_bytes,
|
||||||
contentHash: `${x.hash_code_columns}-${x.hash_code_constraints}`,
|
contentHash: `${x.hash_code_columns}-${x.hash_code_constraints}`,
|
||||||
}))
|
}))
|
||||||
: null,
|
: null,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name"
|
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name",
|
||||||
|
pg_relation_size('"'||infoTables.table_schema||'"."'||infoTables.table_name||'"') as "size_bytes"
|
||||||
from information_schema.tables infoTables
|
from information_schema.tables infoTables
|
||||||
where infoTables.table_type not like '%VIEW%'
|
where infoTables.table_type not like '%VIEW%'
|
||||||
and ('tables:' || infoTables.table_schema || '.' || infoTables.table_name) =OBJECT_ID_CONDITION
|
and ('tables:' || infoTables.table_schema || '.' || infoTables.table_name) =OBJECT_ID_CONDITION
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_
|
|||||||
)) as "hash_code_constraints"
|
)) as "hash_code_constraints"
|
||||||
from information_schema.table_constraints infoConstraints
|
from information_schema.table_constraints infoConstraints
|
||||||
where infoConstraints.table_schema = infoTables.table_schema and infoConstraints.table_name = infoTables.table_name
|
where infoConstraints.table_schema = infoTables.table_schema and infoConstraints.table_name = infoTables.table_name
|
||||||
)
|
),
|
||||||
|
pg_relation_size('"'||infoTables.table_schema||'"."'||infoTables.table_name||'"') as "size_bytes"
|
||||||
|
|
||||||
from information_schema.tables infoTables
|
from information_schema.tables infoTables
|
||||||
where infoTables.table_type not like '%VIEW%'
|
where infoTables.table_type not like '%VIEW%'
|
||||||
|
|||||||
Reference in New Issue
Block a user