Can I substitute sqlite for native php functionality without an unacceptable performance hit?
In php I am retrieving 2 sets of data from subsequent API calls returning around 100 records each.
One set represents parent objects the other none, one or two child objects matching up with a record in the parent set based on a shared key value.
I had planned to store the values in an object and those records in an array which I could then loop through and filter as needed. But perhaps that's overkill. Once the page runs it will ca开发者_如何学Pythonche for around two hours.
Could I just clear two sqlite tables each time the page retrieves data, insert them, and then run a query instead of doing the process with objects and arrays?
I am willing to accept an extra 2 seconds of overhead for added simplicity. Is sqlite able to perform 100 inserts in each of two tables and a select query with a join in that amount of time.
Why not just try it? Two seconds on your given hardware is liable to be different to two seconds on mine, so if this is a meaningful constraint, then you need to actually implement and measure how long it takes.
i.e.: Don't estimate what you can measure.
However, as a completely off the cuff guesstimate (that I won't stand behind and will in fact repudiate in a casual, perhaps slightly mocking manner whilst shaking my head in the manner of a disappointed uncle), I'd be surprised if it took SQLite two seconds to carry out what you're trying to do.
Provided you use a transaction, SQLite can do thousands of inserts in a second so it should cope with a hundred or so easily. Using a transaction is the key, if you don't it'll create a transaction automatically for each insert individually which slows things way down. Querying with a join is not really its strongest point, but if your query structure isn't overly complex I'd imagine it could do it all inside the two seconds.
That's just a guess though, in reality it all depends though on your exact database schema, data and hardware. The only way to really know is to try it and see.
精彩评论