I was working on a program which needs a cache system. so the description is I got a mysql db which has 4 columns, 'mac','src','username','main' Which mac,src,username are key/values and foreign key in main table. it will insert to those 3 first and put their ID in main. The data I got is about 18m for main table, and for those 3 about 2m each. I dont want to use a select everytime it needs to insert in main, so I used an array to cache them. $hash= ['mac'=>[],'src'=>[],'username'=>[]]; and store 'n fetch data like this : $hash['mac']['54:52:00:27:e4:91'];
This approach got bad performance when the hash data's goo beyond 500k ; So is there any better way to do this ?
PS: I got same thing with nodeJS which i used a npm module named hashtable And Performance was about 10k inserts each 4m. I've read about php arrays and found out they are Hashtables , but now it do the same job with far wayslower, for only 1k it takes atleast 5minutes;