Improvement to database indexing

Signed-off-by: crynobone <crynobone@gmail.com>