I had ventricular extrasystoles for a very long time of my life (18-37). This is a mostly harmless arrytmia that feels like one beat out of the normal rhythm. Around 18, I noticed it for the first time. It came and went, usually I had this for ~3 weeks and then it was gone. Over the years however, I got more and more of those and at the age of 30, I had them ~70% of the year at a rate of 5-6/min. In parallel, I felt stressed and depressed. Not from the fact that I had those, I got used to that over the years, which was not easy.
The doctors I went to said: Harmless, learn to live with it, you will still get very old. Especially the five cardiologists but also the "normal" doctor I saw never took that serious at all. I kept a diary over the years and knew that those could fully go away and I had the feeling that it was somehow correlated with what I eat. Whenever I said that, the response was: "Unlikely, you just don't pay enough attention and do not notice them anymore". Treatment advice was: Live with it or get a catheter ablation done.
Then I then went to a different doctor who actually listened to me when I said they could fully go away. She tested me for vitamin D, B12, magnesium, potassium, iron and a few other things. It turned out that I had a strong vitamin D deficiency (12 ng/ml) and a mild MG/K/B12 deficiency.
Then I took some supplements (a bit of D/MG/K/B each). That helped a bit, but not always and not consistently, but I could definitely tell that there was a relation to taking something or not. I prefer a healthy diet over supplements, so I was not very consistent taking those and when everything was good I simply stopped. The fact that this did help, but not always, kept bugging me though and I wanted to figure out what exactly helped. Long story (~5 years of experimenting) short: It most likely was the combination of D and MG, taking one in isolation did not always improve things. There seems to be a mutual dependency between them, which also seems to be studied to some extend (I started to read med publications at some point, e.g. [0]), but I am a computer scientist and not a doctor so take this with a grain of salt and definitely do not just take stuff without measuring the actual levels first.
Today, I occassionally take supplements (still do not like the idea of taking them on a regular basis) and get my D level tested every once in a while. It is now usually ~30 ng/ml which is still a bit low, but the extrasystoles are fully gone (I am 44 now).
[0] Role of Magnesium in Vitamin D Activation and Function, https://pubmed.ncbi.nlm.nih.gov/29480918/