Enhance db querying for getting thread list and thread info