Corrige la vue alis_view pour des problemes de perfs

This commit is contained in:
Alban Crommer 2013-11-06 09:28:06 +00:00
parent 265f3af83a
commit 1a9d69b702
3 changed files with 88 additions and 16 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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`

View File

@ -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);