From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Wed, 07 Nov 2007 15:12:03 -0800 Subject: [sup-talk] [PATCH] Show unread message count in thread index In-Reply-To: <1194469570-sup-4239@tomsk> References: <1194256715-sup-4315@lankhmar> <1194400626-sup-6556@south> <1194430991-sup-3015@lankhmar> <1194465975-sup-3345@south> <1194469570-sup-4239@tomsk> Message-ID: <1194476394-sup-4617@south> Excerpts from Marcus Williams's message of Wed Nov 07 13:09:10 -0800 2007: > Is there any way to get the new message count without search for > unread labels? Nope. Unread is just another label, so you've got to do the search. > How fast is that in ferret? Pretty fast! $ sh devel/console.sh [Wed Nov 07 15:03:42 -0800 2007] loading index... [Wed Nov 07 15:03:42 -0800 2007] loaded index of 65765 messages >> require 'benchmark' >> all = "+label:unread -label:deleted -label:killed -label:spam" >> inbox = all + " +label:inbox" >> puts Benchmark.measure { Index.ferret.search(all).total_hits } 0.020000 0.000000 0.020000 ( 0.015534) >> Index.ferret.search(all).total_hits => 57551 >> puts Benchmark.measure { Index.ferret.search(inbox).total_hits } => nil >> Index.ferret.search(inbox).total_hits => 13 The number in parentheses is elapsed real time. Probably fast enough to call on every keypress, but feel free to cache it if you like. > What happens if your result set has 60k messages in it, does it chew > memory? Nope. Play around with the methods above. Ferret is pretty good about this. > I cant imagine having 60k new messages, but on initial sup-sync you > might on a big mailbox. As you can see above, 57k of the 66k messages in my index are new. (It's the last few years of ruby-talk.) Have I blown your mind? :) -- William