From 1a9d69b70282d39ff5de7b79d2e757c26b83eef8 Mon Sep 17 00:00:00 2001 From: Alban Crommer Date: Wed, 6 Nov 2013 09:28:06 +0000 Subject: [PATCH] Corrige la vue alis_view pour des problemes de perfs --- .gitattributes | 1 + install/mysql.sql | 59 ++++++++++++++++++++++++++---------- install/upgrades/3.2.1~a.sql | 44 +++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 install/upgrades/3.2.1~a.sql diff --git a/.gitattributes b/.gitattributes index 0718e5ae..72f56b5f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -542,6 +542,7 @@ install/upgrades/3.0.3~a.sql -text install/upgrades/3.0.3~b.sh -text install/upgrades/3.1.0~a.sql -text install/upgrades/3.1.0~b.php -text +install/upgrades/3.2.1~a.sql -text install/upgrades/README -text lang/.svnignore -text lang/README -text diff --git a/install/mysql.sql b/install/mysql.sql index 27dfa518..b9fa7011 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -643,22 +643,49 @@ where `address`.`enabled` = 1 -- CREATE OR REPLACE VIEW `alias_view` AS -select concat(`address`.`address`,'@',`domaines`.`domaine`) AS `mail`, -concat(if(isnull(`mailbox`.`id`),'',concat(concat(`address`.`address`,'@',`domaines`.`domaine`),'\n')),`recipient`.`recipients`) AS `alias` -from (((`recipient` join `address` on((`address`.`id` = `recipient`.`address_id`))) -left join `mailbox` on((`mailbox`.`address_id` = `address`.`id`))) -join `domaines` on((`domaines`.`id` = `address`.`domain_id`))) -where `address`.`enabled` = 1 -union -select distinct concat(`m`.`login`,'@',`v`.`value`) AS `mail`, -`m`.`mail` AS `alias` -from ((`membres` `m` join `variable` `v`) join `domaines` `d`) -where (`v`.`name` = 'mailname_bounce') -union -select distinct concat('alterncpanel','@',`v`.`value`) AS `mail`, -`m`.`mail` AS `alias` -from ((`membres` `m` join `variable` `v`) join `domaines` `d`) -where (`v`.`name` = 'mailname_bounce' AND `m`.`uid`=2000); + +-- Generate all the alias configured by the users +select + concat(`address`.`address`,'@',`domaines`.`domaine`) AS `mail`, + concat(if(isnull(`mailbox`.`id`), + '', + concat(concat(`address`.`address`,'@',`domaines`.`domaine`),'\n')), + `recipient`.`recipients`) AS `alias` +from + ( + ((`recipient` join `address` on((`address`.`id` = `recipient`.`address_id`))) + left join `mailbox` on((`mailbox`.`address_id` = `address`.`id`)) + ) + join `domaines` on((`domaines`.`id` = `address`.`domain_id`)) + ) +where + `address`.`enabled` = 1 + +UNION + +-- Generate the alias for all the account +-- Example : account gaylord will have gaylord@FQDN +-- as an alias to his email account. FQDN can be +-- changed in variable mailname_bounce +select + distinct concat(`m`.`login`,'@',`v`.`value`) AS `mail`, + `m`.`mail` AS `alias` +from + ((`membres` `m` join `variable` `v`) join `domaines` `d`) +where + `v`.`name` = 'mailname_bounce' + +UNION + +-- Generate an alias alterncpanel@FQDN to admin mail +select + distinct concat('alterncpanel','@',`v`.`value`) AS `mail`, + `m`.`mail` AS `alias` +from + ((`membres` `m` join `variable` `v`) join `domaines` `d`) +where + (`v`.`name` = 'mailname_bounce' AND `m`.`uid`=2000); + -- -- Structure de la table `piwik_users` diff --git a/install/upgrades/3.2.1~a.sql b/install/upgrades/3.2.1~a.sql new file mode 100644 index 00000000..575c5fee --- /dev/null +++ b/install/upgrades/3.2.1~a.sql @@ -0,0 +1,44 @@ +CREATE OR REPLACE VIEW `alias_view` AS + +-- Generate all the alias configured by the users +select + concat(`address`.`address`,'@',`domaines`.`domaine`) AS `mail`, + concat(if(isnull(`mailbox`.`id`), + '', + concat(concat(`address`.`address`,'@',`domaines`.`domaine`),'\n')), + `recipient`.`recipients`) AS `alias` +from + ( + ((`recipient` join `address` on((`address`.`id` = `recipient`.`address_id`))) + left join `mailbox` on((`mailbox`.`address_id` = `address`.`id`)) + ) + join `domaines` on((`domaines`.`id` = `address`.`domain_id`)) + ) +where + `address`.`enabled` = 1 + +UNION + +-- Generate the alias for all the account +-- Example : account gaylord will have gaylord@FQDN +-- as an alias to his email account. FQDN can be +-- changed in variable mailname_bounce +select + distinct concat(`m`.`login`,'@',`v`.`value`) AS `mail`, + `m`.`mail` AS `alias` +from + ((`membres` `m` join `variable` `v`) join `domaines` `d`) +where + `v`.`name` = 'mailname_bounce' + +UNION + +-- Generate an alias alterncpanel@FQDN to admin mail +select + distinct concat('alterncpanel','@',`v`.`value`) AS `mail`, + `m`.`mail` AS `alias` +from + ((`membres` `m` join `variable` `v`) join `domaines` `d`) +where + (`v`.`name` = 'mailname_bounce' AND `m`.`uid`=2000); +