patch for sqlcounter, please test!