James Cloos wrote:
> This query in psql does give me the header of a message sent to this
> group:
> 
> ,----
> | select physmessage_id from dbmail_messageblks where is_header = 1
> |    and convert_from(messageblk,'SQL_ASCII') ~ 'dbmail-dev' limit 1;
> `----
> 
> It is, however, as one might expect quite slow.
> 
> If one blindly uses 'SQL_ASCII', octets other than those from in /[\n\t -~]/
> aka /\n\t\x20-\x7E/ seem to be output as C-style backslash escapes.
> That may or may not be useful for imap search.
> 
> There is also the question of whether imap search is supposed to search
> the over-the-wire format of the mail or the as-viewed-in-an-MUA format.
> Ie, how imap search and mime are supposed to interact.

The RFC is very clear on that one:

      Server implementations MAY exclude [MIME-IMB] body parts with
      terminal content media types other than TEXT and MESSAGE from
      consideration in SEARCH matching.

So we don't need to match base64 encoded data, etc.

Also consider this:

      In all search keys that use strings, a message matches the key if
      the string is a substring of the field.  The matching is
      case-insensitive.

We try to avoid regexp matching for (possibly) historical performance
reasons, hence the use of ILIKE.

> This query would get all of the mail which have 'dmail-dev' in their
> bodies, ordered by physmessage_id.  But it is wildly disk intensive,
> as psql has to read through every messageblk in dbmail_messageblks.

No way around that without full text indexing.




-- 
  ________________________________________________________________
  Paul Stevens                                      paul at nfg.nl
  NET FACILITIES GROUP                     GPG/PGP: 1024D/11F8CD31
  The Netherlands________________________________http://www.nfg.nl
_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

Reply via email to