For 2M samples this is about 100Mb. If it gets really large, implementing an on-disk key-value store (redis, rocksDB or just mysql) may be necessary.