This patch exposes query.cc::notmuch_query_count_threads to Ruby, the benchmark on 85k emails is amazing: user system total real query.count_threads 6.270000 0.240000 6.510000 ( 6.507064) query.search_threads.count 14.040000 3.130000 17.170000 ( 17.172222)