-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: a non-blocking driver #27
Comments
I agree with you and i hope to see the task (in the internal task manager) of completely redesigning DB in the foreseeable future. Related: |
spiral-modules/database#56 is different, as far as i understand ( google translation lol ), it's about connection pool, which would allow executing multiple queries in parallel, however, this issue is more about non-blocking connections, so that when a query is running, it allows for other callbacks within an event loop to continue execution. |
It is different but related. I think without connection pool we won't be able to support properly a non-blocking database drivers |
Hmm, not really. pool would allow executing multiple queries at the same time, while a non-blocking driver allows executing a query without blocking the event loop, so you can execute a query, send an http request, and execute a shell command, in parallel. |
At the same time it is necessary to block the using connection or provide another connection if a second query must be executed in parallel with the first. |
Not really, assuming the driver is non-blocking, and we are not using a pool, given this code:
both Attempting this using only non-blocking drives:
will also work, but with a big difference, that is the second query will not actually start until the first one is finished, this is achieved using queued operations in a lower level ( https://github.com/amphp/postgres/blob/v2/src/Connection.php#L66-L77 ), by waiting for any previous operations to finish before starting a new one. But, when using a connection pool, this will running concurrently, given that the query method retrieves a new connection for each query. |
so supporting just non-blocking drivers, would be huge, as currently it blocks spiral/roadrunner-worker#19. pools will allow for concurrent queries, but they are not as important as non-blocking drivers. ref: doctrine/dbal#5117 |
With the arrival of PHP 8.1, async code in PHP land doesn't have to use Promise or fall into the callback hell that we got trapped into before.
If cycle would provide an integration with a non-blocking database driver, this would mean that the ORM could be used to do multiple operations in parallel at the application level, and would allow for handling multiple connections as the worker level ( spiral/roadrunner-worker#19 ).
Currently, there's 2 available packages that allow you to create a non-blocking database connection:
The text was updated successfully, but these errors were encountered: