Synchronous and asynchronous query execution
Queries can be executed against the database synchronously or asynchronously. The correct execution paradigm to use depends on the application.
Synchronous execution
Synchronous query execution is blocking, meaning nothing else in the application proceeds until the result from the query is returned. The application blocks for the entire round trip, from when the query is first sent to the database until the results are retrieved and returned to the application.
The advantage of synchronous queries is that it is simple to tell when a query completes, so the execution logic of the application is easy to follow. However, synchronous queries cause poor application throughput.
Asynchronous execution
Asynchronous query execution is more complex. An asynchronous query execute call does not block for results. Instead, a future is immediately returned from the asynchronous execute call. A future is a placeholder object that stands in for the result until the result is returned from the database. Depending on the driver and feature set of the language, this future can facilitate asynchronous processing of results. This typically allows high throughput.