Improve performance to execute COUNT(*) sql without derived query