ManojMarathayil
ManojMarathayil

Reputation: 742

How expensive is IMAP search?

In our application we want to issue imap_search very frequently, like

$result = imap_search($mbox,'ON "20-May-2008" SUBJECT "ip list" TO "[email protected]" FROM "[email protected]"');

How IMAP search is implemented? is it using a linear walk? if yes, what is the alternative for this?

thanks

Upvotes: 2

Views: 1217

Answers (1)

A Jolly Geek
A Jolly Geek

Reputation: 262

The thing to take note of here is that the php imap_search function is making a search request from your imap client to the mail server. The server then takes this request and processes it on the server side with logic specific to the particular imap server. Therefore, unless you know the internal details of the imap server, you don't know how the search is implemented.

You may well have one imap server that will implement the search efficiently while a different imap server implements it poorly. So with large mailboxes you may have searches that run slowly and consume significant resources on the server.

I would think the only alternative to avoiding slow searches would be to code your own mailbox manager that synchronizes with the imap server and does all searches locally, by an efficient algorithm you write to run against a data store of your choosing. Not an easy task.

Upvotes: 2

Related Questions