Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do major DB vendors not provide truly asynchronous APIs?

I work with Oracle and Mysql, and I struggle to understand why the APIs are not written such that I can issue a call, go away and do something else, and then come back and pick it up later eg NIO - I am forced to dedicate a thread to waiting for data. It seems that the SQL interfaces are the only place where sync IO is still forced, which means tying up a thread waiting for the DB.

Can anybody explain the reasons for this? Is there something fundamental that makes this difficult?

It would be great to be able to use 1-2 threads to manage my DB query issue and result fetch, rather than use worker threads to retrieve data.

I do note that there are two experimental attempts (eg: adbcj) at implementing an async API but none seem to be ready for Production use.

like image 516
jasonk Avatar asked Nov 04 '22 00:11

jasonk


1 Answers

Database servers should be able to handle thousands of clients. To provide an asyncronous interface, the DB server will need to keep the resultset from the query in memory, so you can pick it up at later stage. It will quickly become out of resources.

like image 109
Maxim Krizhanovsky Avatar answered Nov 15 '22 06:11

Maxim Krizhanovsky