mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
analyse mysql views optimalization #273
This commit is contained in:
parent
0209780f1c
commit
ee7198a913
@ -56,15 +56,21 @@ class Analyser extends DatabaseAnalyser {
|
||||
|
||||
async getViewTexts(allViewNames) {
|
||||
const res = {};
|
||||
for (const viewName of this.getRequestedViewNames(allViewNames)) {
|
||||
try {
|
||||
const resp = await this.driver.query(this.pool, `SHOW CREATE VIEW \`${viewName}\``);
|
||||
res[viewName] = resp.rows[0]['Create View'];
|
||||
} catch (err) {
|
||||
console.log('ERROR', err);
|
||||
res[viewName] = `${err}`;
|
||||
}
|
||||
|
||||
const views = await this.safeQuery(this.createQuery('viewTexts', ['views']));
|
||||
for (const view of views.rows) {
|
||||
res[view.pureName] = `CREATE VIEW \`${view.pureName}\` AS ${view.viewDefinition}`;
|
||||
}
|
||||
|
||||
// for (const viewName of this.getRequestedViewNames(allViewNames)) {
|
||||
// try {
|
||||
// const resp = await this.driver.query(this.pool, `SHOW CREATE VIEW \`${viewName}\``);
|
||||
// res[viewName] = resp.rows[0]['Create View'];
|
||||
// } catch (err) {
|
||||
// console.log('ERROR', err);
|
||||
// res[viewName] = `${err}`;
|
||||
// }
|
||||
// }
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ const programmables = require('./programmables');
|
||||
const procedureModifications = require('./procedureModifications');
|
||||
const functionModifications = require('./functionModifications');
|
||||
const uniqueNames = require('./uniqueNames');
|
||||
const viewTexts = require('./viewTexts');
|
||||
|
||||
module.exports = {
|
||||
columns,
|
||||
@ -22,4 +23,5 @@ module.exports = {
|
||||
functionModifications,
|
||||
indexes,
|
||||
uniqueNames,
|
||||
viewTexts,
|
||||
};
|
||||
|
7
plugins/dbgate-plugin-mysql/src/backend/sql/viewTexts.js
Normal file
7
plugins/dbgate-plugin-mysql/src/backend/sql/viewTexts.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = `
|
||||
select
|
||||
TABLE_NAME as pureName,
|
||||
VIEW_DEFINITION as viewDefinition
|
||||
from information_schema.views
|
||||
where TABLE_SCHEMA = '#DATABASE#' and TABLE_NAME =OBJECT_ID_CONDITION;
|
||||
`;
|
Loading…
Reference in New Issue
Block a user