On Mon, Jul 09 2012, Sebastien Binet <binet@cern.ch> wrote:
> I was trying to reduce the I/O stress during my usual email
> fetching+tagging by writing a little program using the go bindings to
> notmuch.
>
> ie:
> db, status := notmuch.OpenDatabase(db_path,
> notmuch.DATABASE_MODE_READ_WRITE)
> query := db.CreateQuery("(tag:new AND tag:inbox)")
> msgs := query.SearchMessages()
> for _,msg := range msgs {
> tag_msg(msg, tagqueries)
> }
>
>
> where tagqueries is a subquery of the form:
> [
> {
> "Cmd": "+to-me",
> "Query": "(to:sebastien.binet@cern.ch and not tag:to-me)"
> },
> {
> "Cmd": "+sci-notmuch",
> "Query": "from:notmuch@notmuchmail.org or to:notmuch@notmuchmail.org or subject:notmuch"
> }
> ]
Hi, Sebastian. It's really hard for me to believe that this is much
faster than simply making the two tagging calls in full:
notmuch tag +to-me -- tag:new and tag:inbox and (to:sebastien.binet@cern.ch and not tag:to-me)
notmuch tag +sci-notmuch -- tag:new and tag:inbox and from:notmuch@notmuchmail.org or to:notmuch@notmuchmail.org or subject:notmuch"
After the first call the cache will be fresh, so the overhead should be
minimal. It looks to me you're looking in to this as a post-new hook.
I do pretty much the same thing, and with the above properly constructed
searches the tagging is super fast.
Have you tried profiling the two options? Is it really high I/O stress
on your system? If so, maybe there's another issue that can be
addressed.
As an aside I should point out that a lot of people want to see the
"to:me" search term. But I think the right place to achieve that is in
the query parser.
jamie.