Subject Re: Query that never ends (Firebird 2.5.3)
Author

Dmitry,


After reading your answer, I thought to try changing the order of the things and it Works very quick (I have to check if it Works for my purposes, but it seams it will work). I canĀ“t understand why it Works fine this way but not in the other:


Starting transaction...
Preparing query: select t1.*, t2.* from

(select b1."BJTX",b1."TKEYT",b2."OWNR" as "TOWNR",b2."BJAR",b2."DSCR" as "TDSCR",b2."VOCE",b2."RICH",b2."TEXT" from "TL1_2" b1 left outer join "BJTX" b2 on b1."BJTX"=b2."BJTX") t1

left outer join

(select a1."BJAR",a1."TKEY",a2."OWNR",a2."TIPO",a2."DSCR" as "ADSCR" from "TL1_1" a1 left outer join "BJAR" a2 on a1."BJAR"=a2."BJAR") t2

on t1."BJAR"=t2."BJAR"

order by t2."TKEY",t1."TKEYT"
Prepare time: 0.018s
Field #01: TL1_2.BJTX Alias:BJTX Type:STRING(10)
Field #02: TL1_2.TKEYT Alias:TKEYT Type:STRING(20)
Field #03: BJTX.OWNR Alias:TOWNR Type:STRING(10)
Field #04: BJTX.BJAR Alias:BJAR Type:STRING(10)
Field #05: BJTX.DSCR Alias:TDSCR Type:STRING(400)
Field #06: BJTX.VOCE Alias:VOCE Type:STRING(400)
Field #07: BJTX.RICH Alias:RICH Type:STRING(1)
Field #08: BJTX.TEXT Alias:TEXT Type:BLOB SUB_TYPE 0
Field #09: TL1_1.BJAR Alias:BJAR Type:STRING(10)
Field #10: TL1_1.TKEY Alias:TKEY Type:STRING(80)
Field #11: BJAR.OWNR Alias:OWNR Type:STRING(10)
Field #12: BJAR.TIPO Alias:TIPO Type:STRING(1)
Field #13: BJAR.DSCR Alias:ADSCR Type:STRING(200)
PLAN SORT (JOIN (JOIN (T1 B1 NATURAL, T1 B2 INDEX (BJTX_PK)), JOIN (T2 A1 INDEX (TL1_1_PK), T2 A2 INDEX (BJAR_PK))))


Executing...
Done.
1502539 fetches, 18 marks, 20034 reads, 18 writes.
0 inserts, 0 updates, 0 deletes, 227984 index, 91644 seq.
Delta memory: 60898428 bytes.
Total execution time: 1.546s
Script execution finished.