Salut a tous
en lisant les differents forum, j'ai capté une table de corespondance entre le pourcentage qu'il faut donner a la commande "ANALYSE" et le nombre de lignes dans la table.
Voici cette correspondance:
Vous confirmez cette table? ou avez-vous une approche differente?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Fewer than 10,000 rows: Exact calculation (COMPUTE) Fewer than 100,000 rows: ESTIMATE with 30 % of the table Fewer than 1,000,000 rows: ESTIMATE with 10 % of the table Fewer than 10,000,000 rows: ESTIMATE with 3 % of the table More than 10,000,000 rows: ESTIMATE with 1% of the table
D?autre part, je voudrais avec SQL ou PL/SQL (surement plus facil en PL)
faire une requete qui consulte les tables du shema, et en fonction du nombre de lignes, crée dynamiquement les commande ANALYSE qui correspondent.
J'ai commencé mais je coince dans les IF, peu etre ce script existe deja...
Ca marche ca?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 DECLARE v_table_Name VARCHAR(50); v_nrow number; begin SELECT TABLE_NAME, NUM_ROWS INTO v_table_name, v_nrow FROM DBA_TABLES; IF v_nrow >0 AND v_nrow <10000 THEN DBMS_OUTPUT.PUT_LINE('ANALYZE '||TABLE_NAME||' ESTIMATE STATISTICS COMPUTE'); ELSE IF v_nrow >10001 AND v_nrow <100000 THEN DBMS_OUTPUT.PUT_LINE('ANALYZE '||TABLE_NAME||' ESTIMATE STATISTICS SAMPLE 30 PERCENT'); IF v_nrow >100001 AND v_nrow <1000000 THEN DBMS_OUTPUT.PUT_LINE('ANALYZE '||TABLE_NAME||' ESTIMATE STATISTICS SAMPLE 10 PERCENT'); ... end;
D'avance merci pour le coup de main
Partager