MySQL degrading performance over many (~10-100K) short select queries

I’m currently building an app on Node with MySQL database where on the initial run I have to calculate ~250M items. Each calculation takes 3 SELECT statements.
I’m testing with a couple of thousands for now to understand what affects the performance. I’m seeing weird behaviour. Initially calculations run really quick, 1k gets processed in under a second. Then, after some (~20k) thousands are run it slows down to about 4 seconds per 1k.