Subject Closing a query problem
Author Theo Bebekis
Hi

I run the below (nightmarish) select

select
od.ID ID
,od.CODE_ID CODE_ID
,od.ORDER_DATE ORDER_DATE
,od.END_DATE END_DATE
,cu.ID CUST_ID
,cu.NAME CUST_NAME
,od.W_ORDER W_ORDER
,(select sum(A_W + B_W + C_W ) from PROD_DIARY where EVENT_ID in (select ID from EVENT_DIARY where ORDER_ID = ORDERS.ID))
as W_DONE
,(select sum(A_W_F + B_W_F + C_W_F ) from PROD_DIARY where EVENT_ID in (select ID from EVENT_DIARY where ORDER_ID = ORDERS.ID))
as W_FAULT
,(select sum(A_R + B_R + C_R ) from PROD_DIARY where EVENT_ID in (select ID from EVENT_DIARY where ORDER_ID = ORDERS.ID))
as R_DONE
,(select sum(A_R_F + B_R_F + C_R_F ) from PROD_DIARY where EVENT_ID in (select ID from EVENT_DIARY where ORDER_ID = ORDERS.ID))
as R_FAULT
,(select sum(WEIGHT) from SD_ITEMS where SHIP_DIARY_ID in (select ID from SHIP_DIARY where ORDER_ID = ORDERS.ID))
as W_SHIP
,(select sum(ROLLS) from SD_ITEMS where SHIP_DIARY_ID in (select ID from SHIP_DIARY where ORDER_ID = ORDERS.ID))
as R_SHIP
,te.ID TEXT_ID
,te.NAME TEXT_NAME
,od.LOT LOT
,od.GAUGES GAUGES
,od.LOOPS LOOPS
,od.CLOTH_WEIGHT CLOTH_WEIGHT
,od.NOTES NOTES
,od.DONE DONE
from
ORDERS od
,CUSTOMERS cu
,TEXTURES te
where
od.CUST_ID = cu.ID
and od.TEXTURE_ID = te.ID


It returns the 500 records of the table in less than 1 second.
But when I "close" the query, that is Query1.Active := False,
I get the below delays

42 seconds, when the select is the SQL.Text of a Query component
45 seconds, when the select is the body of a view (select * from view_name)
26 seconds, when the select is the body of a stored procedure (select * from sp_name).

I wonder why it takes so much time to "close" the query
while it takes only 1 second to execute it.

The Windows (W2K) Task Manager shows that the time is consumed
by the ibserver.exe, not by the test app I use.

That means when I do Active := False, Task Manager says that
Firebird consumes the 99% of the CPU time for the seconds
I described above

My test done using
Firebird 1 and Firebird 1.2
IBX and ZEOS components
Delphi 5 through 7
Always the same results.

Well, my select is far from a state-of-art.
But why it takes so long for the Firebird to close it?

Regards
Theo

-----------------------------------
Theo Bebekis
Thessaloniki, Greece
bebekis@...
teo@...
-----------------------------------