Use fewer sql statements to format tiles