当我运行以下 SQL 在 3000 条记录的数据库中创建视图时,它可以工作,但是当我在更大的数据库中运行 9000 条记录时,ORA 01256 和其他提到临时空间和内存不足的异常在执行后生成需很长时间。
如果我只是从 select 开始运行 SQL 查询,它可以工作..实际发生了什么?
CREATE OR REPLACE FORCE VIEW "PM"."LOCATION_TEST" ("GROUPA_TYPE",
"GROUPA_FOLDER_ID", "GROUPA_FOLDER_NAME", "GROUPB_TYPE", "GROUPB_FOLDER_ID",
"GROUPB_FOLDER_NAME", "GROUPC_TYPE", "GROUPC_FOLDER_ID", "GROUPC_FOLDER_NAME",
"GROUPD_TYPE", "GROUPD_FOLDER_ID", "GROUPD_FOLDER_NAME", "GROUPE_TYPE",
"GROUPE_FOLDER_ID", "GROUPE_FOLDER_NAME") AS
select distinct "GROUPA_TYPE","GROUPA_FOLDER_ID","GROUPA_FOLDER_NAME",
"GROUPB_TYPE","GROUPB_FOLDER_ID","GROUPB_FOLDER_NAME","GROUPC_TYPE",
"GROUPC_FOLDER_ID","GROUPC_FOLDER_NAME","GROUPD_TYPE","GROUPD_FOLDER_ID",
"GROUPD_FOLDER_NAME","GROUPE_TYPE","GROUPE_FOLDER_ID","GROUPE_FOLDER_NAME"
from
(
select parent_4.*, product.ftype as groupe_type , customer_folder.customer_folder_id
as groupe_folder_id , customer_folder.folder_name as groupe_folder_name
from
customer_folder
left join product
on customer_folder.customer_folder_ID = product.folder_id
right join
(
select parent_3.*, product.ftype as groupd_type , customer_folder.customer_folder_id as
groupd_folder_id , customer_folder.folder_name as groupd_folder_name
from
customer_folder
left join product
on customer_folder.customer_folder_ID = product.folder_id
right join
(
select parent_2.*, product.ftype as groupc_type , customer_folder.customer_folder_id as groupc_folder_id , customer_folder.folder_name as groupc_folder_name
from
customer_folder
left join product
on customer_folder.customer_folder_ID = product.folder_id
right join
(
select parent_1.*, product.ftype as groupb_type ,
customer_folder.customer_folder_id
as groupb_folder_id, customer_folder.folder_name as groupb_folder_name
from
customer_folder
left join product
on customer_folder.customer_folder_ID = product.folder_id
right join
(
select product.ftype as groupa_type , customer_folder_id as
groupa_folder_id, folder_name as groupa_folder_name
from customer_folder
left join product
on customer_folder.customer_folder_ID = product.folder_id
where parent_folder_id = 1
) parent_1
on
customer_folder.parent_folder_id = parent_1.groupa_folder_id ) parent_2
on
customer_folder.parent_folder_id = parent_2.groupb_folder_id ) parent_3
on
customer_folder.parent_folder_id = parent_3.groupc_folder_id ) parent_4
on
customer_folder.parent_folder_id = parent_4.groupd_folder_id );