Whelp, nextcloud isn't known for being fast. I don't have hundreds of thousands of emails yet so I can't comment on that, but one thing for sure is as you put more and more data on it, you'll have to add more CPU and RAM to it or it'll getting more and more sluggish.
The last few updates to nextcloud and PHP 8 have drastically improved performance for me. I'm not using the Mail app but SnappyMail, and everything works pretty well.
Older versions and PHP < 8 were pretty slow even with all of the optimizations.
NC Webmail UI is poorly designed: compose window is just a small box on the center of the screen, there’s no way to have the markup tools permanently show up;
NC Webmail UI is broken: if you select a bunch of text and turn it into a bullet list, the bullets won’t even show up on NC, other e-mail clients will see them tho;
Integration/SSO with IMAP is cumbersome: not well documented, default configuration doesn’t even handle a simple “login with the email email and password as the IMAP account” type of setup that is commonly expected;
WebUI is slow and fails often: if you open the browser console you’ll find lots of warnings and errors.
I do have a lot of complaints related to mail but if NC is any kind of useful replacement for MS365 / Google Workplace a decently working webmail is the bare minimum. RoundCube is WAY better than what NC is currently offering.