Optimization of database queries. Two (wip)