HHH-8864 count distinct tuples for postgres and h2