Dql optimization