add hand optimized sql