Board index » delphi » Select Sum generate multi connections

Select Sum generate multi connections

We have an ISAPI app accessing a SQL Server Database. The WebModule has one
ADOConnection and all the ADOQueries are connected to the database through
the ADOConnection.
But when the AdoQuery executes a select like "select Sum(value) as A from
mytable where ..." the sql trace shows an prepare on the database with
"select * from mytable". Before the prepare the app made a connect and after
the prepare, a disconnect.
In some actions, the app has to execute this select a lot of times, and,
becouse of this, a lot of connections are made with the database, and this
increase the time of the app response.
Why the adoquery with sum (and count) do this prepare, and have to connect
and disconnect ?
Why, if I do this select with this sintax: "select (select Sum(value) as A
from mytable where ...) as A" this problem do not occur ?
 

Re:Select Sum generate multi connections


Quote
>Why the adoquery with sum (and count) do this prepare, and have to connect
>and disconnect ?

ISAPI applications create a new instance each time they run.  That includes a
new data module so it has a new connection and a new query to deal with.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Select Sum generate multi connections


The problem occurs in he same thread. We made the same test in a Windows app
(exe) with the same results. When we open an adoquery with "select
sum(value) as A from table where..." the sql trace shows that, to do this
select, the app have to make a connect, prepare "select * from table" and a
disconnect from the database. The adoquery was linked with an adoconnection
which was connected before the open. For this, we don't understand why the
app made another connection, and why, with this select - "select (select
Sum(value) as A
from mytable where ...) as A" - this problem do not occurs.

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:59350v0bgqu9suj0cpqhjj7bl2ja2n1i0d@4ax.com...

Quote

> >Why the adoquery with sum (and count) do this prepare, and have to
connect
> >and disconnect ?

> ISAPI applications create a new instance each time they run.  That
includes a
> new data module so it has a new connection and a new query to deal with.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Other Threads