Working on #738 Database optimization
Add indexes in several places and combined indexes in other places