Le 06/11/2012 21:03, Jan-Henrik Haukeland a écrit :
Hi
The reason is that the other alternative, mysql_store_result() read the result set into the client and can potentially use a lot of memory. By doing it with statement, we can get away with using a minimum amount of memory, basically the memory required to hold one row only.
Fair enough. We mainly do requests with few results, and were using mysql_store_result before trying libzdb, so this memory usage issue didn't cross my mind at first.
I just took a look at the MySQL API again and came over mysql_use_result() [1] which seems to support the strategy mentioned above. That is, to read result set partially. It might be that this call will use less CPU. If you can demonstrate that mysql_real_query() + mysql_use_result() use significant less CPU and about the same amount (or less) memory as the existing implementation I'll be happy to change this part in libzdb.
Yes, but the documentation indicates that "This ties up the server and prevent other threads from updating any tables from which the data is being fetched". This may seem strange (why would that happen here and not for prepared statements with the same strategy ?) and may need to be checked, but does not look appealing. These kind of things would make me want to be able to choose which strategy to use per-request, alas I fear that's not the kind of thing that could make it into your library.
For now we have to do our own quick fix (for our specific case). We will think about what we can do in the long term later.