optimize database access by adding indexs