Turns out, your microbiome will shift significantly within a few days of changing your diet [0]. A more recent study showed that increasing raw vegetables in your diet significantly changed microbiome at about the same speed [1].
However, because the _effects_ of a healthy microbiome are things like better vitamin reception and disease prevention [2] [3], it can take months to see the effects of something like better B12 can take weeks to see [4]. Disease prevention of metabolic diseases takes years to see fully.
[0] https://www.scientificamerican.com/article/the-guts-microbio... [1] https://news.harvard.edu/gazette/story/2019/10/study-finds-g... [2] https://en.wikipedia.org/wiki/Human_microbiome#Disease_and_d... [3] https://depts.washington.edu/ceeh/downloads/FF_Microbiome.pd... [4] https://www.nhs.uk/medicines/cyanocobalamin/