optimize mysql class