Bonjour,
j'ai créé une table de cette manière:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| CREATE or replace TYPE BANNER_LIST AS TABLE OF NUMBER
/
CREATE TABLE ADEXPR03.WEB_PLAN_MEDIA_MONTH_FRED
(
ID_MEDIA NUMBER(10,0) NOT NULL,
ID_PRODUCT NUMBER(10,0) NOT NULL,
MONTH_MEDIA_NUM NUMBER(6,0) NOT NULL,
TOTALUNITE NUMBER(10,0) NULL,
LIST_BANNERS BANNER_LIST
)
NESTED TABLE LIST_BANNERS STORE AS WEB_PLAN_MEDIA_MONTH_TAB
TABLESPACE DATAWEB01ADEXPR03
NOLOGGING
PCTFREE 10
PCTUSED 0
INITRANS 1
MAXTRANS 255
STORAGE(BUFFER_POOL DEFAULT)
NOPARALLEL
CACHE
NOROWDEPENDENCIES
/ |
j'aurai quelques millions de lignes chaque jour à insérer du genre:
1 2 3 4 5 6 7 8 9 10 11 12 13
| insert into ADEXPR03.WEB_PLAN_MEDIA_MONTH
SELECT
DP.Id_media,
DP.Id_product,
SUBSTR(DP.Date_media_num,1,6) as M,
SUM(INSERTION) as totalinsert,
Wm_Concat(DISTINCT HASHCODE)
FROM ADEXPR03.DATA_EVALIANT DP
WHERE DP.DATE_MEDIA_NUM >= 20160101 and DP.DATE_MEDIA_NUM < 20160401
and id_media=11366
and id_product in (840239,838503,837806,835583,835570)
GROUP BY DP.Id_Media, DP.Id_product, SUBSTR(DP.Date_media_num,1,6)
order by 3,2 |
ID_MEDIA ID_PRODUCT M TOTALINSERT WM_CONCAT(DISTINCTHASHCODE)
11366 835570 201601 9 37147179
11366 835583 201601 7 37152794,37209502,37212347,37498709,37498831
11366 837806 201601 1 37085353
11366 838503 201601 3 36807422,36807430,36808400
11366 840239 201601 3 37152000,37152758
11366 837806 201602 1 36940535
11366 838503 201602 6 36807422,36808400
11366 840239 201602 1 37152000
11366 840239 201603 1 37415174
actuellement, la colonne LIST_BANNERS est juste un VARCHAR2, mais le wm_concat prend 75% du temps à l'insertion.
je voulais savoir si il était possible d'insérer dynamiquement en colonne les valeurs retournées par le wm_concat dans la table proposée plus haut.
car je peux facilement insérer de cette manière :
1 2 3
| INSERT INTO ADEXPR03.WEB_PLAN_MEDIA_MONTH_FRED VALUES (11366,835570,201601,9,BANNER_LIST(37147179));
INSERT INTO ADEXPR03.WEB_PLAN_MEDIA_MONTH_FRED VALUES (11366,835583,201601,7,BANNER_LIST(37152794,37209502,37212347,37498709,37498831));
... |
mais je voudrais que ce soit fait dans la requête d'insertion:
1 2 3 4 5 6 7 8 9 10 11 12 13
| insert into ADEXPR03.WEB_PLAN_MEDIA_MONTH_FRED
SELECT
DP.Id_media,
DP.Id_product,
SUBSTR(DP.Date_media_num,1,6) as M,
SUM(INSERTION) as totalinsert,
XXXXX(distinct HASHCODE)
FROM ADEXPR03.DATA_EVALIANT DP
WHERE DP.DATE_MEDIA_NUM >= 20160101 and DP.DATE_MEDIA_NUM < 20160401
and id_media=11366
and id_product in (840239,838503,837806,835583,835570)
GROUP BY DP.Id_Media, DP.Id_product, SUBSTR(DP.Date_media_num,1,6)
order by 3,2 |
je ne vois pas comment faire cette insertion dans une nested table...
Merci pour votre aide
Partager