Search very slow

Hi,

I'm searching for messages in a message folder ("Inbox", 72 MB, about 100 messages) with a given message ID:

SearchTerm st =new HeaderTerm("Message-ID", messageId);

Message[] msgs = folder.search(st);

This search lasts about 1 minute and more. I think the message file is a very small one. What can I do to speed up this search?

[423 byte] By [Holger_Riessa] at [2007-10-3 4:58:51]
# 1

I'm going to take a 'shot' at this.

By default I believe the folder.search(SearchTerm) method does a getMessages() call (which would be pretty slow with the numbers you have given).

Are you using POP3 or IMAP?

I'm assuming you are using POP3 as the IMAP provider uses the IMAP server's search capabilities and POP3 uses the default method mentioned above.

If you aren't using POP3 and my assumptions are completely wrong, it could be an issue with the mail server (try connecting with telnet and sending the appropriate commands that way).

Let me know either way

--

travis (at) overwrittenstack.com

travis_fergusona at 2007-7-14 23:04:14 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
I'm using POP3. Do you think that every mail in the box is fetched with getMessages() and after this the search term will be evaluated? This would take a long time.
Holger_Riessa at 2007-7-14 23:04:14 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

[url]http://java.sun.com/products/javamail/javadocs/javax/mail/Folder.html#search(javax.mail.search.SearchTerm)[/url]

states this is the case.POP3Message does not override this method, IMAPMessage does.

Is there a IMAP Server setup on the same server as your current POP3 server (a lot of times there is).

-

travis (at) overwrittenstack.com

Message was edited by:

travis_ferguson

Fixed my url/link tags.

travis_fergusona at 2007-7-14 23:04:14 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Note that getMessages doesn't fetch anything from the server,

even for pop3. The data isn't fetched until you need it.

For the search you're doing, only the message headers will

be needed, so that's all that will be fetched. Yes, that's still

expensive, but not as expensive as fetching the entire messages.

bshannona at 2007-7-14 23:04:14 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...