From: Per Jessen on
Tommy Pham wrote:

> Here's my analysis, let's say that you have 1000 requests / second on=

> the web server. Each request has multiqueries which take a total of =
1
> second to complete. In that one second, how many of those 1000 arriv=
e
> at the same time (that one instant of micro/nano second)?=20

On average, exactly one per millisecond.=20


/Per

--=20
Per Jessen, Z=C3=BCrich (15.4=C2=B0C)

From: Lester Caine on
Per Jessen wrote:
> Tommy Pham wrote:
>
>> I'm presenting the argument for threading. Per is presenting the work
>> around using asynchronous queries via mysqlnd. I did read that link a
>> few days ago, "Although the user can send multiple queries at once,
>> multiple queries cannot be sent over a busy connection. If a query is
>> sent while the connection is busy, it waits until the last query is
>> finished and discards all its results." Which sounds like threads ->
>> multiple connections to not run into that problem.
>
> You must have read the wrong page. This is NOT about multiple queries,
> it's about _asynchronous_ queries.

The only problem here is what the database client can handle. If it can only
handle one active query, then that is all that can be used. It can be started
asynchronously and then you come back to pick up the results later, and so you
can be formating the page ready to insert the results. PDO requires that you
start a different connection in a different transaction for each of these
queries, but that is another hot potato. Running 10 asynchronous queries would
require 10 connections as that is how the database end works. Adding threading
to PHP is going to make no difference?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
From: Peter Lind on
On 25 March 2010 22:51, Lester Caine <lester(a)lsces.co.uk> wrote:
> Per Jessen wrote:
>>
>> Tommy Pham wrote:
>>
>>> I'm presenting the argument for threading.  Per is presenting the work
>>> around using asynchronous queries via mysqlnd.  I did read that link a
>>> few days ago, "Although the user can send multiple queries at once,
>>> multiple queries cannot be sent over a busy connection. If a query is
>>> sent while the connection is busy, it waits until the last query is
>>> finished and discards all its results."  Which sounds like threads ->
>>> multiple connections to not run into that problem.
>>
>> You must have read the wrong page.  This is NOT about multiple queries,
>> it's about _asynchronous_ queries.
>
> The only problem here is what the database client can handle. If it can only
> handle one active query, then that is all that can be used. It can be
> started asynchronously and then you come back to pick up the results later,
> and so you can be formating the page ready to insert the results. PDO
> requires that you start a different connection in a different transaction
> for each of these queries, but that is another hot potato. Running 10
> asynchronous queries would require 10 connections as that is how the
> database end works. Adding threading to PHP is going to make no difference?

Actually, this sounds very close to having 10 threads each opening a
connection to the database and running the query ... which was the
solution to the scenario presented, if memory serves.

> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>
From: Tommy Pham on
On Thu, Mar 25, 2010 at 1:50 PM, Per Jessen <per(a)computer.org> wrote:
> Tommy Pham wrote:
>
>> I'm presenting the argument for threading.  Per is presenting the work
>> around using asynchronous queries via mysqlnd.  I did read that link a
>> few days ago, "Although the user can send multiple queries at once,
>> multiple queries cannot be sent over a busy connection. If a query is
>> sent while the connection is busy, it waits until the last query is
>> finished and discards all its results."  Which sounds like threads ->
>> multiple connections to not run into that problem.
>
> You must have read the wrong page.  This is NOT about multiple queries,
> it's about _asynchronous_ queries.
>
>
That quote is comming directly from that link Peter Lind gave, which
I read a few days ago. Did you read it?
From: Tommy Pham on
On Thu, Mar 25, 2010 at 3:04 PM, Tommy Pham <tommyhp2(a)gmail.com> wrote:
> On Thu, Mar 25, 2010 at 1:50 PM, Per Jessen <per(a)computer.org> wrote:
>> Tommy Pham wrote:
>>
>>> I'm presenting the argument for threading. Per is presenting the work
>>> around using asynchronous queries via mysqlnd. I did read that link a
>>> few days ago, "Although the user can send multiple queries at once,
>>> multiple queries cannot be sent over a busy connection. If a query is
>>> sent while the connection is busy, it waits until the last query is
>>> finished and discards all its results." Which sounds like threads ->
>>> multiple connections to not run into that problem.
>>
>> You must have read the wrong page. This is NOT about multiple queries,
>> it's about _asynchronous_ queries.
>>
>>
> That quote is comming directly from that link Peter Lind gave, which
> I read a few days ago. Did you read it?
>

Here's the entire description:

" pg_send_query() sends a query or queries asynchronously to the connection
.. Unlike pg_query(), it *can send multiple queries at once to PostgreSQL*and
*get the results one by one using pg_get_result().*

Script execution is not blocked while the queries are executing. Use
pg_connection_busy() to check if the connection is busy (i.e. the query is
executing). Queries may be cancelled using pg_cancel_query().

*Although the user can send multiple queries at once, multiple queries
cannot be sent over a busy connection. If a query is sent while the
connection is busy, it waits until the last query is finished and discards
all its results.*"

Any case, that's only workaround for mysql (mysqlnd) & postgresql. What
about those that uses other RDBMS?