Feature Requests item #1973673, was opened at 2008-05-27 01:04
Message generated for change (Comment added) made by lenix
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=937967&aid=1973673&group_id=191583
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Christian Boltz (christian_boltz)
Assigned to: Nobody/Anonymous (nobody)
Summary: merge SQL queries for alias domains
Initial Comment:
>From POSTFIX_CONF.txt:
virtual_alias_maps =
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_maps =
proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
This means MySQL is called twice for mailboxes and three times for aliases (except if the first try returns a result, of course).
If possible, we should merge the queries so that alias and mailbox queries always only need one map.
SELECT ... UNION SELECT ... UNION SELECT ...
doesn't look very nice, but it has a better performance than doing two or three separate queries.
Or is there a special reason why we should do separate queries?
----------------------------------------------------------------------
Comment By: Guido Boehm (lenix)
Date: 2008-06-08 20:02
Message:
Logged In: YES
user_id=142401
Originator: NO
hi christian,
after re-thinking the way postfix does lookups it appears to me it already
does run 2 queries per item in 'virtual_alias_maps':
- a first try for exact matches (looking up the key 'bo...@ex...')
- if the first try didn't give any results a second try for catchall
(looking up the key '@example.com')
based on this assumption i created the following query which should be
able to replace the 3 virtual_alias_maps-queries in the current setup:
SELECT alias.goto
FROM alias
LEFT JOIN alias_domain ON alias_domain.alias_domain = '%d'
WHERE alias.active = 1
AND (
alias.address='%s'
OR
(alias_domain.alias_domain='%d' AND
alias.address=CONCAT('%u','@',alias_domain.target_domain))
)
although i did run a set of test-queries against my own database which
looked promising i don't have the time to extensivly test it inside my
postfix-setup right now. i'll try to do this next week and keep you
updated.
thanks for your patience, lenix
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=937967&aid=1973673&group_id=191583
|