I am using an API which has a limit on requests. The API response is in XML and typically it is around 8 kB big.To say short: I want to eliminate to exactly send the same requests twice to the API.
There can be over 2 million requests with their appropriate answers. So when I get that amount of XML responses copied to records in MySQL, will it respond fast enough if I query it?
Table structure:
- id int PK Auto Increment
- request_parameters TEXT UNIQUE
- response TEXT
I found MySQL Query Cache, but I think its only handy for much requested requests. The other will maybe slow down?
I also found Varnish, but it seems to me more a HTML/code cache.
I assume:
responsefrom a givenrequest_parameters(...WHERE request_parameters = 'some string')request_parametersare not too long (under 1000 characters)I advise:
Drop your ID column. Although some people recommend always using an integer as a primary key, I understand you are not trying to build a relational database. You just need one table for storage.
Change your
request_parameterscolumn types toVARCHAR(x), “x” being the largest expected size of a parameter string.Make
request_parametersthe primary key.As advised by PLB, store the serialized version of your XML responses.
2 millions rows of such data will require several Gb, plus some space for the index. If you have a hell lot of available memory on your system, and if you can afford loosing all your data when you restart MySQL, then you might want to go for a try with MEMORY table.