On Thu, Oct 31, 2024 at 12:52:51PM +0100, Thomas Landauer via Postfix-users wrote: > Hi, > > yeah, I think the docs about the connection are clearer now :-) > > However, the "three queries behavior" is still undocumented IMO. I did read > https://www.postfix.org/virtual.5.html and it is nicely explained there. > But my point is: If somebody is configuring the database lookup at > `local_recipient_maps`, they will not read those docs about virtual tables! > Why should they? > So I think this should be explained at other places too. > > > For my own setup, I have just one question: > I have two domains at `mydestination`, and I want a separate database lookup > for each, then pipe the mail to a separate external command. > The transport part works so nicely: > > transport_maps = inline:{ foo.com=foo_handler, bar.com=bar_handler } > > But for the recipients, I can't see a way of mapping the 2 domains to 2 > lookup tables. So my current "workaround" looks something like this: > > local_recipient_maps = pgsql:foo.cf pgsql:bar.cf > > And then (since both queries will be run) in the SQL do something like: > > > query = SELECT id FROM table WHERE 'foo.com' = '%d' AND local_part = '%u' >
Simpler, and more efficient, since no SQL queries will be issued for addresses that are not @foo.com: domain = foo.com query = SELECT id FROM table WHERE local_part = '%u' This is documented: domain (default: no domain list) This is a list of domain names, paths to files, or type:table databases. When specified, only fully qualified search keys with a *non-empty* localpart and a matching domain are eligible for lookup: user lookups, bare domain lookups and @domain lookups are not performed. This can significantly reduce the query load on the PostgreSQL server. domain = postfix.org, hash:/etc/postfix/searchdomains It is best not to use SQL to store the domains eligible for SQL lookups. This parameter is available with Postfix 2.2 and later. NOTE: DO NOT define this parameter for local(8) aliases, because the input keys are always unqualified. -- Viktor. _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org