Improve SQL performance using counter cache