optimise query/db structure - todo