Версия Firebird 1.5.3
Вот все планы:
Код: Выделить всё
Select SUM(tdetails.stl_amount) Sum_STL_Amount,
COUNT(tstl_operation.operation) COUNT_OPER,
SUM(tdetails.tran_fee) SUM_Tran_FEE,
SUM(tdetails.tran_amount) SUM_Tran_Amount,
SUM(tdetails.stl_fee) SUM_STL_FEE
From tpackage, tdocument, tsettlement, tstl_operation, tdetails
Where tpackage.name='settlement' and
tdocument.date_doc=:date_doc and
tdetails.stl_ccy=980 and
tdetails.tran_type <> '70' and
tpackage.id_pack=tdocument.pack_id and
tdocument.id_doc=tsettlement.doc_id and
tsettlement.id_set=tstl_operation.set_id and
tstl_operation.id_stl=tdetails.stl_id
План
PLAN JOIN (TSTL_OPERATION NATURAL,TSETTLEMENT INDEX (PK_TSETTLEMENT),TDOCUMENT INDEX (PK_TDOCUMENT),TPACKAGE INDEX (PK_TPACKAGE),TDETAILS INDEX (TDETAILS_STL_ID))
Адаптированный план
PLAN JOIN (TSTL_OPERATION NATURAL,TSETTLEMENT INDEX (PK_TSETTLEMENT),TDOCUMENT INDEX (PK_TDOCUMENT),TPACKAGE INDEX (PK_TPACKAGE),TDETAILS INDEX (TDETAILS_STL_ID))
------ Performance info ------
Prepare time = 0ms
Execute time = 250ms
Avg fetch time = 250,00 ms
Current memory = 11 190 160
Max memory = 12 734 640
Memory buffers = 2 048
Reads from disk to cache = 0
Writes from cache to disk = 0
Fetches from cache = 121 397
Код: Выделить всё
Select SUM(tdetails.stl_amount) Sum_STL_Amount,
COUNT(tstl_operation.operation) COUNT_OPER,
SUM(tdetails.tran_fee) SUM_Tran_FEE,
SUM(tdetails.tran_amount) SUM_Tran_Amount,
SUM(tdetails.stl_fee) SUM_STL_FEE
From tpackage, tdocument, tsettlement, tstl_operation, tdetails
Where tpackage.name='settlement' and
tdocument.date_doc=:date_doc and
tdetails.stl_ccy=980 and
tdetails.tran_type <> '70' and
tdetails.tran_type <> '21' and
tpackage.id_pack=tdocument.pack_id and
tdocument.id_doc=tsettlement.doc_id and
tsettlement.id_set=tstl_operation.set_id and
tstl_operation.id_stl=tdetails.stl_id
План
PLAN JOIN (TDETAILS INDEX (TDETAILS_STL_CCY),TSTL_OPERATION INDEX (PK_TSTL_OPERATION),TSETTLEMENT INDEX (PK_TSETTLEMENT),TDOCUMENT INDEX (PK_TDOCUMENT),TPACKAGE INDEX (PK_TPACKAGE))
Адаптированный план
PLAN JOIN (TDETAILS INDEX (TDETAILS_STL_CCY),TSTL_OPERATION INDEX (PK_TSTL_OPERATION),TSETTLEMENT INDEX (PK_TSETTLEMENT),TDOCUMENT INDEX (PK_TDOCUMENT),TPACKAGE INDEX (PK_TPACKAGE))
------ Performance info ------
Prepare time = 0ms
Execute time = 9s 922ms
Avg fetch time = 9 922,00 ms
Current memory = 11 899 072
Max memory = 12 734 640
Memory buffers = 2 048
Reads from disk to cache = 4 818
Writes from cache to disk = 0
Fetches from cache = 4 034 017
А вот последний запрос с использованием not in
Код: Выделить всё
Select SUM(tdetails.stl_amount) Sum_STL_Amount,
COUNT(tstl_operation.operation) COUNT_OPER,
SUM(tdetails.tran_fee) SUM_Tran_FEE,
SUM(tdetails.tran_amount) SUM_Tran_Amount,
SUM(tdetails.stl_fee) SUM_STL_FEE
From tpackage, tdocument, tsettlement, tstl_operation, tdetails
Where tpackage.name='settlement' and
tdocument.date_doc=:date_doc and
tdetails.stl_ccy=980 and
tdetails.tran_type not in ('70', '21') and
tpackage.id_pack=tdocument.pack_id and
tdocument.id_doc=tsettlement.doc_id and
tsettlement.id_set=tstl_operation.set_id and
tstl_operation.id_stl=tdetails.stl_id
План
PLAN JOIN (TSTL_OPERATION NATURAL,TSETTLEMENT INDEX (PK_TSETTLEMENT),TDOCUMENT INDEX (PK_TDOCUMENT),TPACKAGE INDEX (PK_TPACKAGE),TDETAILS INDEX (TDETAILS_STL_ID))
Адаптированный план
PLAN JOIN (TSTL_OPERATION NATURAL,TSETTLEMENT INDEX (PK_TSETTLEMENT),TDOCUMENT INDEX (PK_TDOCUMENT),TPACKAGE INDEX (PK_TPACKAGE),TDETAILS INDEX (TDETAILS_STL_ID))
------ Performance info ------
Prepare time = 0ms
Execute time = 250ms
Avg fetch time = 250,00 ms
Current memory = 11 190 624
Max memory = 12 734 640
Memory buffers = 2 048
Reads from disk to cache = 50
Writes from cache to disk = 0
Fetches from cache = 121 397