Comments - Non-blocking calls from PHP

5 years, 1 month ago Justin Swanhart Swanhart

I have been working on a native MySQL/MariaDB system that doesn't require using the C client, but instead executes queries (in parallel!) using events.

Feel free to try it out:

5 years, 1 month ago Michael Shestero

Thank you, very interesting! But also it lack of functionality. I want a status function that return not only that a query is completed or in progress, but 3 cases: 1) query is in progress, nothing ready. 2) query is in progress and one can already read N records/rows in unbuffered mode (or just one record is ready) while it is in progress. 3) query is completed. [ 4) error ]

5 years, 1 month ago Justin Swanhart Swanhart


You can support the second requirement by using SELECT .. INTO OUTFILE. You could see that the query is in RUNNING state, then open the file in PHP, which will not be completely written until the query completes. This will allow you to get the results in an unbuffered fashion.

To do this with ASYNC, add a hint to the beginning of the query: call async.queue('/*+unbuffered*/select * from mysql.user into outfile "/tmp/test2.txt"');

If you combine that with a UDF to erase the files (there is one in called fb_unlink()) this could be a very workable solution to your problem.

5 years, 1 month ago Michael Shestero

It's not useful to do temporary files in multiuser multitask system.

I know one better way to do the task: you can do unbuffered reading in a separate second PHP scipt and call it from the main script by HTTP (using localhost). Then you can read its TCP-socket asynchronous (it's also not graceful in PHP, but possible).

Node.JS support async requests to MySQL (through new MariaDB clent API). Does anybody know if it's possible to ineract from PHP to Node.JS in a async non-blocking way?

5 years, 1 month ago Justin Swanhart Swanhart

yes it is useful. you assign a random filename then you poll it. but do what you want, the solution I proposed will work just fine

5 years, 1 month ago Justin Swanhart Swanhart

Oh, one more thing, you will need to write the file to a shared filesystem if you aren't running the PHP client on the same machine as the server, but this is trivial. You could use CIFS or NFS for example.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.