The following lines contain the word 'select', 'insert', 'update' or 'delete':
* Procedure : CAL_SELECTIVITY
* Type : Private
* Pre_reqs :
* Parameters :
* input
* p_table_name
* v_colname : array of column name
* numcol : number of name
* output
* v_colname : array of sorted column name by selectivity
* o_sel : array of odinal selectivity
* std_dev : array of standard deviation
*/
PROCEDURE CAL_SELECTIVITY( p_table_name IN varchar2,
v_colname IN OUT NOCOPY name_varray,
o_sel IN OUT NOCOPY value_varray,
std_dev IN OUT NOCOPY value_varray,
flag IN OUT NOCOPY value_varray,
numcol IN integer,
x_return_status OUT NOCOPY varchar2)
IS
l_status VARCHAR2(30);
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.start',
'Start of the procedure jty_tae_index_creation_pvt.cal_selectivity ' || to_char(sysdate,'dd-mm-rrrr HH24:MI:SS'));
SELECT NVL(dt.NUM_ROWS,1)
INTO v_cardinality
FROM dba_tables dt
WHERE dt.owner = l_jtf_schema
AND dt.table_name = p_table_name;
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.cardinality',
'Number of rows for table ' || p_table_name || ' : ' || v_cardinality);
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.cardinality',
'API jty_tae_index_creation_pvt.cal_selectivity has failed as the number of rows in the table ' ||
p_table_name || ' is 0');
SELECT 100 - (NVL(dtc.num_distinct,1)*100/v_cardinality)
INTO o_sel(i)
FROM dba_tab_columns dtc, user_synonyms syn
WHERE syn.synonym_name = UPPER(p_table_name)
AND dtc.owner = syn.table_owner
AND dtc.table_name = syn.table_name
AND dtc.column_name = UPPER(v_colname(i));
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.bubble_sort',
'API jty_tae_index_creation_pvt.bubble_sort has failed');
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.end',
'End of the procedure jty_tae_index_creation_pvt.cal_selectivity ' || to_char(sysdate,'dd-mm-rrrr HH24:MI:SS'));
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.l_schema_notfound',
'Schema name corresponding to JTF application not found');
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.no_data_found',
substr(SQLCODE || ' : ' || SQLERRM, 1, 4000));
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.g_exc_error',
'jty_tae_index_creation_pvt.cal_selectivity has failed with G_EXC_ERROR exception');
'jtf.plsql.jty_tae_index_creation_pvt.cal_selectivity.others',
substr(SQLCODE || ' : ' || SQLERRM, 1, 4000));
END CAL_SELECTIVITY;
* Procedure : DEA_SELECTIVITY
* Type : Private
* Pre_reqs :
* Description :
* Parameters :
* input JTY_DEA_ATTR_FACTORS.SQUAL_ALIAS
* outout JTY_DEA_ATTR_FACTORS.INPUT_SELECTIVITY is populated with selectivity order
JTY_DEA_ATTR_FACTORS.INPUT_ORDINAL_SELECTIVITY is populated with ordinal_selectivity
JTY_DEA_ATTR_FACTORS.INPUT_DEVIATION is populated with standard deviation
*/
PROCEDURE DEA_SELECTIVITY(p_TABLE_NAME IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2)
IS
-- SOLIN, Bug 5893926
-- extend to 300 elements
col_name name_varray := name_varray(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
SELECT DISTINCT
A.TAE_COL_MAP sqname,
A.INPUT_DEVIATION dev,
A.INPUT_ORDINAL_SELECTIVITY ord_sele,
A.INPUT_SELECTIVITY sele,
decode(A.UPDATE_SELECTIVITY_FLAG,'Y',1,0) flag
FROM JTY_DEA_ATTR_FACTORS A
WHERE A.USE_TAE_COL_IN_INDEX_FLAG = 'Y'
AND A.TAE_COL_MAP is not null ;
'jtf.plsql.jty_tae_index_creation_pvt.dea_selectivity.start',
'Start of the procedure jty_tae_index_creation_pvt.dea_selectivity ' || to_char(sysdate,'dd-mm-rrrr HH24:MI:SS'));
'jtf.plsql.jty_tae_index_creation_pvt.dea_selectivity.col_name',
'API jty_tae_index_creation_pvt.dea_selectivity has failed as there is no valid column name, or all flag = No');
CAL_SELECTIVITY(
p_table_name => p_table_name,
v_colname => col_name,
o_sel => o_sel,
std_dev => std_dev,
flag => flag,
numcol => i-1,
x_return_status => x_return_status);
'jtf.plsql.jty_tae_index_creation_pvt.dea_selectivity.cal_selectivity',
'API jty_tae_index_creation_pvt.cal_selectivity has failed');
UPDATE JTY_DEA_ATTR_FACTORS
SET INPUT_SELECTIVITY = i,
INPUT_ORDINAL_SELECTIVITY = o_sel(i),
INPUT_DEVIATION = std_dev(i)
WHERE TAE_COL_MAP = col_name(i);
'jtf.plsql.jty_tae_index_creation_pvt.dea_selectivity.end',
'End of the procedure jty_tae_index_creation_pvt.dea_selectivity ' || to_char(sysdate,'dd-mm-rrrr HH24:MI:SS'));
'jtf.plsql.jty_tae_index_creation_pvt.dea_selectivity.g_exc_error',
'jty_tae_index_creation_pvt.dea_selectivity has failed with G_EXC_ERROR exception');
'jtf.plsql.jty_tae_index_creation_pvt.dea_selectivity.others',
substr(SQLCODE || ' : ' || SQLERRM, 1, 4000));
END DEA_SELECTIVITY;
* Procedure : SELECTIVITY
* Type : Private
* Pre_reqs :
* Description :
* Parameters :
* input JTF_TAE_QUAL_FACTORS.SQUAL_ALIAS
* outout JTF_TAE_QUAL_FACTORS.INPUT_SELECTIVITY is populated with selectivity order
JTF_TAE_QUAL_FACTORS.INPUT_ORDINAL_SELECTIVITY is populated with ordinal_selectivity
JTF_TAE_QUAL_FACTORS.INPUT_DEVIATION is populated with standard deviation
*/
PROCEDURE SELECTIVITY(p_TABLE_NAME IN VARCHAR2,
p_mode IN VARCHAR2,
p_source_id IN NUMBER,
x_return_status OUT NOCOPY VARCHAR2)
IS
col_name name_varray := name_varray(
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
SELECT DISTINCT
A.TAE_COL_MAP sqname,
A.INPUT_DEVIATION dev,
A.INPUT_ORDINAL_SELECTIVITY ord_sele,
A.INPUT_SELECTIVITY sele,
decode(A.UPDATE_SELECTIVITY_FLAG,'Y',1,0) flag
FROM JTF_TAE_QUAL_FACTORS A
WHERE A.USE_TAE_COL_IN_INDEX_FLAG = 'Y'
AND A.TAE_COL_MAP is not null ;
SELECT DISTINCT
A.VALUES_COL_MAP sqname,
NULL dev,
A.INPUT_ORDINAL_SELECTIVITY ord_sele,
A.INPUT_SELECTIVITY sele,
1 flag
FROM jty_terr_values_idx_details A,
jty_terr_values_idx_header B
WHERE A.VALUES_COL_MAP is not null
AND B.delete_flag = 'N'
AND A.terr_values_idx_header_id = B.terr_values_idx_header_id
AND B.source_id = cl_source_id;
SELECT DISTINCT
A.VALUES_COL_MAP sqname,
NULL dev,
A.INPUT_ORDINAL_SELECTIVITY ord_sele,
A.INPUT_SELECTIVITY sele,
1 flag
FROM jty_dea_values_idx_details A,
jty_dea_values_idx_header B
WHERE A.VALUES_COL_MAP is not null
AND A.dea_values_idx_header_id = B.dea_values_idx_header_id
AND B.source_id = cl_source_id;
'jtf.plsql.jty_tae_index_creation_pvt.selectivity.start',
'Start of the procedure jty_tae_index_creation_pvt.selectivity ' || to_char(sysdate,'dd-mm-rrrr HH24:MI:SS'));
'jtf.plsql.jty_tae_index_creation_pvt.selectivity.col_name',
'API jty_tae_index_creation_pvt.selectivity has failed as there is no valid column name, or all flag = No');
CAL_SELECTIVITY(
p_table_name => p_table_name,
v_colname => col_name,
o_sel => o_sel,
std_dev => std_dev,
flag => flag,
numcol => i-1,
x_return_status => x_return_status);
'jtf.plsql.jty_tae_index_creation_pvt.selectivity.cal_selectivity',
'API jty_tae_index_creation_pvt.selectivity has failed');
UPDATE JTF_TAE_QUAL_FACTORS
SET INPUT_SELECTIVITY = i,
INPUT_ORDINAL_SELECTIVITY = o_sel(i),
INPUT_DEVIATION = std_dev(i)
WHERE TAE_COL_MAP = col_name(i);
UPDATE jty_dea_values_idx_details
SET INPUT_SELECTIVITY = i,
INPUT_ORDINAL_SELECTIVITY = o_sel(i)
WHERE VALUES_COL_MAP = col_name(i);
UPDATE jty_terr_values_idx_details
SET INPUT_SELECTIVITY = i,
INPUT_ORDINAL_SELECTIVITY = o_sel(i)
WHERE VALUES_COL_MAP = col_name(i);
'jtf.plsql.jty_tae_index_creation_pvt.selectivity.end',
'End of the procedure jty_tae_index_creation_pvt.selectivity ' || to_char(sysdate,'dd-mm-rrrr HH24:MI:SS'));
'jtf.plsql.jty_tae_index_creation_pvt.selectivity.g_exc_error',
'jty_tae_index_creation_pvt.selectivity has failed with G_EXC_ERROR exception');
'jtf.plsql.jty_tae_index_creation_pvt.selectivity.others',
substr(SQLCODE || ' : ' || SQLERRM, 1, 4000));
END SELECTIVITY;
SELECT P.qual_product_id qual_product_id,
p.RELATION_PRODUCT RELATION_PRODUCT,
MAX(p.index_name) index_name,
MAX(p.first_char_flag) first_char_flag,
COUNT(r.qual_factor_id) cartesian_terr_X_factors
FROM jtf_terr_denorm_rules_all d
,jtf_terr_qtype_usgs_all jtqu
,jtf_qual_type_usgs_all jqtu
,JTF_TAE_QUAL_PRODUCTS P
, JTF_TAE_QUAL_PROD_FACTORS R
WHERE jtqu.qual_relation_product = p.relation_product
AND jqtu.source_id = d.source_id
AND jqtu.qual_type_id = p.trans_object_type_id
AND d.terr_id = jtqu.terr_id
AND jtqu.qual_type_usg_id = jqtu.qual_type_usg_id
AND d.source_id = p.source_id
AND P.qual_product_id = R.qual_product_id
AND P.BUILD_INDEX_FLAG = 'Y'
AND p.TRANS_OBJECT_TYPE_ID = cl_trans_id
AND P.SOURCE_ID = cl_source_id
GROUP BY P.qual_product_id, p.RELATION_PRODUCT
ORDER BY cartesian_terr_X_factors DESC, first_char_flag;
SELECT DISTINCT TAE_COL_MAP, J2.INPUT_SELECTIVITY
FROM JTF_TAE_QUAL_PRODUCTS J3,
JTF_TAE_QUAL_FACTORS J2,
JTF_TAE_QUAL_PROD_FACTORS J1
WHERE J1.qual_product_id = c_pid
AND J1.qual_product_id = J3.qual_product_id
AND J1.qual_factor_id = J2.qual_factor_id
AND J2.USE_TAE_COL_IN_INDEX_FLAG = 'Y'
AND J2.TAE_COL_MAP is NOT NULL
ORDER BY J2.INPUT_SELECTIVITY;
SELECT P.qual_product_id qual_product_id,
p.RELATION_PRODUCT RELATION_PRODUCT,
p.index_name index_name,
p.first_char_flag first_char_flag,
rownum index_counter
FROM JTF_TAE_QUAL_PRODUCTS P
WHERE P.BUILD_INDEX_FLAG = 'Y'
AND P.FIRST_CHAR_FLAG = 'Y'
AND p.TRANS_OBJECT_TYPE_ID = cl_trans_id
AND P.SOURCE_ID = cl_source_id;
select f.tae_col_map, qual_usg_id, input_selectivity
from jtf_tae_qual_prod_factors pf,
jtf_tae_qual_factors f
where pf.qual_product_id = cl_pid
and f.qual_factor_id = pf.qual_factor_id
and f.tae_col_map is not null
order by input_selectivity desc;
select NON_NULL_TAE_COL_MAPS, RELATION_PRODUCT
from (
select count(*) NON_NULL_TAE_COL_MAPS,
p.qual_product_id QUAL_PRODUCT_ID,
p.relation_product RELATION_PRODUCT
from JTF_TAE_QUAL_products p,
JTF_TAE_QUAL_prod_factors pf,
JTF_TAE_QUAL_FACTORS f
where p.qual_product_id = pf.qual_product_id
and pf.qual_factor_id = f.qual_factor_id
and p.source_id = cl_source_id
and p.trans_object_type_id = cl_trans_id
and p.relation_product > 0
and tae_col_map is not null
and p.relation_product = cp_product
group by p.qual_product_id, p.relation_product
)
where NON_NULL_TAE_COL_MAPS = cp_non_null_tae_col_maps;
SELECT P.dea_attr_products_id dea_attr_products_id,
p.attr_relation_product attr_relation_product,
MAX(p.index_name) index_name,
MAX(p.first_char_flag) first_char_flag,
COUNT(r.dea_attr_factors_id) cartesian_terr_X_factors
FROM jty_denorm_dea_rules_all d
,jtf_terr_qtype_usgs_all jtqu
,jtf_qual_type_usgs_all jqtu
,jty_dea_attr_products P
,jty_dea_attr_prod_factors R
WHERE jtqu.qual_relation_product = p.attr_relation_product
AND jqtu.source_id = d.source_id
AND jqtu.qual_type_id = p.trans_type_id
AND d.terr_id = jtqu.terr_id
AND jtqu.qual_type_usg_id = jqtu.qual_type_usg_id
AND d.source_id = p.source_id
AND P.dea_attr_products_id = R.dea_attr_products_id
AND P.build_index_flag = 'Y'
AND p.trans_type_id = cl_trans_id
AND P.source_id = cl_source_id
GROUP BY P.dea_attr_products_id, p.attr_relation_product
ORDER BY cartesian_terr_X_factors DESC, first_char_flag;
SELECT DISTINCT TAE_COL_MAP, J2.INPUT_SELECTIVITY
FROM jty_dea_attr_products J3,
jty_dea_attr_factors J2,
jty_dea_attr_prod_factors J1
WHERE J1.dea_attr_products_id = c_pid
AND J1.dea_attr_products_id = J3.dea_attr_products_id
AND J1.dea_attr_factors_id = J2.dea_attr_factors_id
AND J2.USE_TAE_COL_IN_INDEX_FLAG = 'Y'
AND J2.TAE_COL_MAP is NOT NULL
ORDER BY J2.INPUT_SELECTIVITY;
SELECT P.dea_attr_products_id dea_attr_products_id,
p.attr_relation_product attr_relation_product,
p.index_name index_name,
p.first_char_flag first_char_flag,
rownum index_counter
FROM jty_dea_attr_products P
WHERE P.BUILD_INDEX_FLAG = 'Y'
AND P.FIRST_CHAR_FLAG = 'Y'
AND p.trans_type_id = cl_trans_id
AND P.source_id = cl_source_id;
select f.tae_col_map, qual_usg_id, input_selectivity
from jty_dea_attr_prod_factors pf,
jty_dea_attr_factors f
where pf.dea_attr_products_id = cl_pid
and f.dea_attr_factors_id = pf.dea_attr_factors_id
and f.tae_col_map is not null
order by input_selectivity desc;
select NON_NULL_TAE_COL_MAPS, attr_relation_product
from (
select count(*) NON_NULL_TAE_COL_MAPS,
p.dea_attr_products_id dea_attr_products_id,
p.attr_relation_product attr_relation_product
from jty_dea_attr_products p,
jty_dea_attr_prod_factors pf,
jty_dea_attr_factors f
where p.dea_attr_products_id = pf.dea_attr_products_id
and pf.dea_attr_factors_id = f.dea_attr_factors_id
and p.source_id = cl_source_id
and p.trans_type_id = cl_trans_id
and p.attr_relation_product > 0
and tae_col_map is not null
and p.attr_relation_product = cp_product
group by p.dea_attr_products_id, p.attr_relation_product
)
where NON_NULL_TAE_COL_MAPS = cp_non_null_tae_col_maps;
select index_name
from all_indexes
where table_name = cl_table_name
and table_owner = cl_owner;
SELECT MIN(TO_NUMBER(v.value))
INTO l_dop
FROM v$parameter v
WHERE v.name = 'parallel_max_servers'
OR v.name = 'cpu_count';
SELECT i.tablespace, i.index_tablespace, u.oracle_username
INTO l_table_tablespace, l_idx_tablespace, l_ora_username
FROM fnd_product_installations i, fnd_application a, fnd_oracle_userid u
WHERE a.application_short_name = 'JTF'
AND a.application_id = i.application_id
AND u.oracle_id = i.oracle_id;
SELECT index_extn
INTO l_index_extn
FROM jty_trans_usg_pgm_details
WHERE source_id = p_source_id
AND trans_type_id = p_trans_id
AND program_name = p_program_name;
SELECT qual_type_usg_id
INTO l_qual_type_usg_id
FROM jtf_qual_type_usgs_all
WHERE source_id = p_source_id
AND qual_type_id = p_trans_id;
SELECT aidx.owner, aidx.INDEX_NAME
FROM DBA_INDEXES aidx
WHERE aidx.table_name = cl_table_name
AND aidx.table_owner = cl_jtf_schema
AND aidx.index_name not in ('JTF_TAE_TN1002_CASE_N1W', 'JTF_TAE_TN1003_CASE_N1W', 'JTF_TAE_TN1004_CASE_N1W', 'JTF_TAE_TN1105_CASE_N1W', 'JTF_TAE_TN1106_CASE_N1W');