Open RoySegall opened 8 years ago
OK, I found out what's the problem. The first is used XDEBUG and it's slow the performance of PHP but It seems that createCursorFromResponse iterate over the results and create a cursor object.
This could very cool but it's not scaleable. Why not give to improve the DX by 2 ways:
@danielmewes thoughts?
@RoySegall if the full data set fits into memory, there are already two options for getting the result as an array rather than a cursor:
->toArray()
method on the cursor object. This will convert the cursor into an array, but maintain the batched protocol between the client and the server. This has the advantage that less resources are used on the server, but at the cost of some additional communication and protocol overhead.->coerceTo("array")
to the query, before the ->run
. This will perform the array conversion server-side. Can you try if option 2 gives you better performance? It will entirely cut out the cursor part.
I'm working on setting up RethinkDB as a cache layer for Drupal and I saw that when I'm querying a MySQL server the response time is 0.7 seconds and when querying RethinkDB the process takes something like 1.4 seconds.
The request is for 1,000 records:
Eventually, the query is:
And as you can see I created an index for cid. which improve the query from 5 seconds to 1.4.
Profiling the query from RethinkDB side takes about 3ms so the suspect is the Driver.
Any idea?