Best index for GROUP BY query?

Indexing would help you if you had a WHERE clause.

One thing to try is:

CREATE INDEX idx ON mybucket(accountNumber, lastName);

EXPLAIN SELECT accountNumber
FROM mybucket
WHERE accountNumber IS NOT NULL
GROUP BY accountNumber
HAVING …;

Make sure you see cover() in the EXPLAIN output.