ORA
: unable to extend temp segment by
in tablespace TEMP
select GAME_CARD_TYPE
NAME
GAME
NAME GameName
sum(V_SALE_TMP_LOG
GAME_CARD_NUM) as num
sum(V_SALE_TMP_LOG
CITY_AGENT_COST) as sumSalePrice
sum(V_SALE_TMP_LOG
PROVINCE_AGENT_COST) as basePrice
V_SALE_TMP_LOG
SALE_MODE
from V_SALE_TMP_LOG
GAME_CARD_TYPE
GAME
RESELLER_BASE
AGENT_BASE c
AGENT_BASE d
where (V_SALE_TMP_LOG
SALE_MODE=
or V_SALE_TMP_LOG
SALE_MODE=
or V_SALE_TMP_LOG
SALE_MODE=
)
and V_SALE_TMP_LOG
GAME_CARD_TYPE_ID=GAME_CARD_TYPE
GAME_CARD_TYPE_ID(+)
and GAME_CARD_TYPE
GAME_ID=GAME
GAME_ID(+)
and V_SALE_TMP_LOG
RESELLER_ID=RESELLER_BASE
RESELLER_ID
and RESELLER_BASE
AGENT_ID=c
AGENT_ID
and c
PARENT_AGENT_ID = d
AGENT_ID
and V_SALE_TMP_LOG
IS_SUCCESS=
Y
and d
AGENT_ID=
and V_SALE_TMP_LOG
LOG_TIME>=to_date(
:
:
yyyy
mm
dd HH
:MI:SS
) and V_SALE_TMP_LOG
LOG_TIME<=to_date(
:
:
yyyy
mm
dd HH
:MI:SS
)
GROUP BY GAME
name
GAME_CARD_TYPE
NAME
V_SALE_TMP_LOG
SALE_MODE
ORDER BY
sum(V_SALE_TMP_LOG
CITY_AGENT_COST) DESC
sum(V_SALE_TMP_LOG
GAME_CARD_NUM) DESC
這個SQL在執行時將
G的TEMP表空間溢出來
通過lecco sql ecpert對該SQL做了分析
SQL> l
select GAME_CARD_TYPE
NAME
GAME
NAME GameName
sum(V_SALE_TMP_LOG
GAME_CARD_NUM) as num
sum(V_SALE_TMP_LOG
CITY_AGENT_COST) as sumSalePrice
sum(V_SALE_TMP_LOG
PROVINCE_AGENT_COST) as basePrice
V_SALE_TMP_LOG
SALE_MODE
from V_SALE_TMP_LOG
GAME_CARD_TYPE
GAME
RESELLER_BASE
AGENT_BASE c
AGENT_BASE d
where (V_SALE_TMP_LOG
SALE_MODE=
or V_SALE_TMP_LOG
SALE_MODE=
or V_SALE_TMP_LOG
SALE_MODE=
)
and V_SALE_TMP_LOG
GAME_CARD_TYPE_ID=GAME_CARD_TYPE
GAME_CARD_TYPE_ID(+)
and GAME_CARD_TYPE
GAME_ID=GAME
GAME_ID(+)
and V_SALE_TMP_LOG
RESELLER_ID=RESELLER_BASE
RESELLER_ID
and RESELLER_BASE
AGENT_ID=c
AGENT_ID
and c
PARENT_AGENT_ID = d
AGENT_ID
and V_SALE_TMP_LOG
IS_SUCCESS=
Y
and d
AGENT_ID=
and V_SALE_TMP_LOG
LOG_TIME>=to_date(
:
:
yyyy
mm
dd HH
:MI:SS
) and V_SALE_TMP_LOG
LOG_TIME<=to_date(
:
:
yyyy
mm
dd HH
:MI:SS
)
GROUP BY GAME
name
GAME_CARD_TYPE
NAME
V_SALE_TMP_LOG
SALE_MODE
ORDER BY
sum(V_SALE_TMP_LOG
CITY_AGENT_COST) DESC
sum(V_SALE_TMP_LOG
GAME_CARD_NUM) DESC
*
SQL>
rows selected
Elapsed:
:
:
Execution Plan
SELECT STATEMENT Optimizer=ALL_ROWS (Cost=
Card=
Byte
s=
)
SORT (ORDER BY) (Cost=
Card=
Bytes=
)
SORT (GROUP BY) (Cost=
Card=
Bytes=
)
HASH JOIN (OUTER) (Cost=
Card=
Bytes=
)
HASH JOIN (OUTER) (Cost=
Card=
Bytes=
)
NESTED LOOPS (Cost=
Card=
Bytes=
)
NESTED LOOPS (Cost=
Card=
Bytes=
)
NESTED LOOPS (Cost=
Card=
Bytes=
)
INDEX (UNIQUE SCAN) OF
SYS_C
(UNIQU
E) (Cost=
Card=
Bytes=
)
TABLE ACCESS (BY INDEX ROWID) OF
AGENT_BASE
(Cost=
Card=
Bytes=
)
INDEX (RANGE SCAN) OF
IDX_BASE_AGENT_ID
(NON
UNIQUE) (Cost=
Card=
)
TABLE ACCESS (BY INDEX ROWID) OF
RESELLER_BAS
E
(Cost=
Card=
Bytes=
)
INDEX (RANGE SCAN) OF
IDX_RESELLER_BASE_AGE
NT_ID
(NON
UNIQUE) (Cost=
Card=
)
VIEW OF
V_SALE_TMP_LOG
(Cost=
Card=
Bytes=
)
UNION
ALL (PARTITION)
TABLE ACCESS (BY INDEX ROWID) OF
SALE_TMP_L
OG
(Cost=
Card=
Bytes=
)
INDEX (RANGE SCAN) OF
IDX_RESEID_STL
(NO
N
UNIQUE) (Cost=
Card=
)
TABLE ACCESS (BY GLOBAL INDEX ROWID) OF
SAL
E_TMP_LOG_DELETED
(Cost=
Card=
Bytes=
)
INDEX (RANGE SCAN) OF
IDX_SALE_DELETED_LO
G_TIME
(NON
UNIQUE) (Cost=
Card=
)
TABLE ACCESS (FULL) OF
GAME_CARD_TYPE
(Cost=
Ca
rd=
Bytes=
)
TABLE ACCESS (FULL) OF
GAME
(Cost=
Card=
Bytes
=
)
Statistics
recursive calls
db block gets
consistent gets
physical reads
redo size
bytes sent via SQL*Net to client
bytes received via SQL*Net from client
SQL*Net roundtrips to/from client
sorts (memory)
sorts (disk)
rows processed
這是源SQL執行後的結果
SQL> l
select /*+ USE_HASH(V_SALE_TMP_LOG) */ GAME_CARD_TYPE
NAME
GAME
NAME GameName
sum(V_SALE_TMP_LOG
GAME_CARD_NUM) as num
sum(V_SALE_TMP_LOG
CITY_AGENT_COST) as sumSalePrice
sum(V_SALE_TMP_LOG
PROVINCE_AGENT_COST) as basePrice
V_SALE_TMP_LOG
SALE_MODE
from V_SALE_TMP_LOG
GAME_CARD_TYPE
GAME
RESELLER_BASE
AGENT_BASE c
AGENT_BASE d
where (V_SALE_TMP_LOG
SALE_MODE =
or V_SALE_TMP_LOG
SALE_MODE =
or V_SALE_TMP_LOG
SALE_MODE =
)
and V_SALE_TMP_LOG
GAME_CARD_TYPE_ID = GAME_CARD_TYPE
GAME_CARD_TYPE_ID (+)
and GAME_CARD_TYPE
GAME_ID = GAME
GAME_ID (+)
and V_SALE_TMP_LOG
RESELLER_ID = RESELLER_BASE
RESELLER_ID
and RESELLER_BASE
AGENT_ID = c
AGENT_ID
and c
PARENT_AGENT_ID = d
AGENT_ID
and V_SALE_TMP_LOG
IS_SUCCESS =
Y
and d
AGENT_ID =
and V_SALE_TMP_LOG
LOG_TIME >= to_date(
:
:
yyyy
mm
dd HH
:MI:SS
)
and V_SALE_TMP_LOG
LOG_TIME <= to_date(
:
:
yyyy
mm
dd HH
:MI:SS
)
GROUP BY GAME
name
GAME_CARD_TYPE
NAME
V_SALE_TMP_LOG
SALE_MODE
ORDER BY
sum(V_SALE_TMP_LOG
CITY_AGENT_COST) DESC
sum(V_SALE_TMP_LOG
GAME_CARD_NUM) DESC
*
rows selected
Elapsed:
:
:
Execution Plan
SELECT STATEMENT Optimizer=ALL_ROWS (Cost
From:http://tw.wingwit.com/Article/program/Oracle/201311/18515.html