[libcommhistory] Optimize RecentContactsModel query

For a large database of calls and messages, this improves the query time
from about 2100ms to 60ms.
Merge pull request #64 from special/optimize-recentmodel

[libcommhistory] Optimize RecentContactsModel query