DDR5 on AM5 has a sweet spot at about 6000MT/s. The fabric clock (fabric = the interconnect between the CCDs and the memory) on that platform can run in a 1:1 ratio with the RAM. It's good to about 3200MHz (so DDR5-6400), but after this it's necessary to introduce a divider to keep the FCLK running stably. The added latency of the divider and the reduced bandwidth it introduces actually reduce performance when you go faster than DDR5-6400. There's a new DDR5-8000 kit whose bandwidth does overcome this divider penalty, but it's really expensive.
Lower CAS latency also boosts performance. There's a new DDR5-6000 kit at CL26 which performs well at that frequency, but is again very expensive.
So get the fastest RAM you can afford, up to a point. DDR5-6000 CL30 is relatively cheap and offers a solid compromise. Its performance can be tweaked by manually tightening timings, but that is dark magicke indeed.