### Description

![image](https://github.com/elastic/elasticsearch/assets/76245/d0443170-0419-4759-b505-7620ff3d6594)

The execution time of grouping stats by multiple keywords has increased: 1.2 to 1.6 seconds (with doc_partitioning), 4.3 to 6.7 seconds (with shard_partitioning). The equivalent query with the _search API takes 1.8 seconds.

`from nyc_taxis | ... | stats c = count(dropoff_datetime) by trip_type, payment_type, vendor_id`

This regression occurred since July 2, 2023, and I suspect it may be due to the PR: [Support multivalued fields on arbitrary grouping](https://github.com/elastic/elasticsearch-internal/pull/1340).

/cc @nik9000
x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/BatchEncoder.java
}
        return counts[positionOffset];
    }
    /**
     * Read the value at the specified index. Values at the first position
     * start at index {@code 0} and advance one per value. So the values
     * at position n start at {@code (0..n-1).sum(valueCount)}. There is
     * no random-access way to get the first index for a position.
     */
    public final BytesRef read(int index, BytesRef scratch) {
        scratch.bytes = bytes.bytes();
        scratch.offset = valueOffsets[index];
        scratch.length = valueOffsets[index + 1] - scratch.offset;
        return scratch;
    }
    /**
     * Encodes the next batch of entries. This will encode values until the next
     * value doesn't fit into the buffer. Callers should iterate on the values
     * that have been encoded and then call this again for the next batch.
     * <p>
     *     It's possible for this batch to be empty if there isn't room for the
     *     first entry in the buffer. If so, call again to force the buffer to
     *     expand and encode that entry.
     * </p>
     */
    public final void encodeNextBatch() {
        bytes.clear();
        firstPosition += positionCount;
        positionCount = 0;
        currentValue = 0;