Subject Re: [firebird-support] multiple queries
Author Vlad Khorsun
> This is probably a silly question, but I've never had the need to even think
> about it.
>
> Can you run multiple queries at the same time on a connection?

Yes and no.

You can have more than one statement open at the same connection at the
same time, but you can't have more than one API call (on the same connection)
at the same time.

So, this is possible

stmt1 : execute
stmt2 : open cursor
stmt3 : execute
stmt2 : fetch
stmt1 : execute
stmt2 : fetch
...

But you can't do simething like

stmt1 : start execute
stmt2 : open cursor
stmt1 : finish execute


> The question has come up on discussions on making the PHP PDO library work with
> 'Asynchronous Requests' and while it's not something I have had to bother with
> myself, the reasoning behind it does make sense. If you have some data which
> will take a while for the engine to return, a count of records that one can't
> engineer out for instance, so one starts that query but then carry on working to
> build up the rest of the data with other queries. By the time the rest of the
> data has been gathered, the first query may also be finished so the rendering
> time for a page is reduced.
>
> I know that this depends on the application end being able to do multiple
> things, and I've often run things in parallel in the past in C++ but not in PHP.
> But at this stage the question is - can the client interface handle the
> situation. I've seen some threads about this in relation to .net and C++
> threading needing separate connections, but I need to understand if the basic
> link could handle it?

Nor Firebird engine, nor Firebird client not able to handle more than 1 API call
to the same database attachment simultaneously. Before v2.5 application should
take care about syncronization. v2.5 client do it by itself and v2.5 engine also
tracks (and syncronizes) simultaneous access to the same attachment.

Regards,
Vlad