Hi to all.
For first:
"select * from v$version;
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
"CORE 11.2.0.3.0 Production"
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production"
We have the following merge running every night at 0:10 am. The problem is that sometimes it runs in a very long time, 24 hours are not enough and we have to kill it. We have been told by the dba that the merge is very sensitive to the statistics of the tables: after a kill we do a statistics recalculation and the day after the merge goes.
Since we are not looking for maximum performance, but only that it runs in honest times , do you know if there is any hint to put to ignore the statistics on the tables so that the merge is less sensitive to stats??
I am attaching queries and plans, I report the merge below for convenience:
Query&plan.zip (3.49 KB)MERGE /*+ USE_HASH (trg src) */ INTO SRC_SIP_GEN_OSP.TPT_CLAUSOLA trg
USING (
SELECT
*
FROM
(
SELECT
/*+no_index(EL_TPT_CLAUSOLA EL_TPT_CLAUSOLA_PK)*/
NUM\_POLIZZA,
COD\_COMPON,
to\_timestamp(TMS\_INSERIMENTO, 'YYYY-MM-DD HH24:MI:SS.FF9') as TMS\_INSERIMENTO,
REVKEY,
LUNGHEZZA_SEGMENTO,
PROGR,
PROGR_SUB,
IDENT_TESTO,
RAMO_TESTO,
TIPO_TESTO,
COD_TESTO,
VERSIONE_TESTO,
UPPER(UTL_I18N.RAW_TO_CHAR(DATI_TESTO_1)) || UPPER(UTL_I18N.RAW_TO_CHAR(DATI_TESTO_2)) DATI_TESTO,
PARTIZ_FASCIA_POL,
UTENTE_INSERIMENTO,
OP_TS,
OP_TYPE,
TMS_INS_DWH,
POS,
ROW_NUMBER()
OVER(PARTITION BY num_polizza, cod_compon, tms_inserimento, revkey, progr, progr_sub
ORDER BY pos DESC, op_ts DESC
) AS rk
FROM
src_sip_gen_osp.el_tpt_clausola
WHERE
to_number(to_char(to_timestamp(op_ts, 'YYYY-MM-DD HH24:MI:SS.FF6') + INTERVAL '02' HOUR + INTERVAL '00'
MINUTE + INTERVAL '00' SECOND,
'YYYYMMDDHH24MISSFF6')) BETWEEN 20220624201001000000 AND 20220628001012051482
)
WHERE
rk = 1
)
src ON ( trg.num_polizza = src.num_polizza
AND trg.cod_compon=src.cod_compon
AND trg.tms_inserimento = src.tms_inserimento
AND trg.revkey = src.revkey
AND trg.PROGR=src.PROGR
AND trg.PROGR_SUB=src.PROGR_SUB)WHEN MATCHED THEN UPDATE
SET
trg.LUNGHEZZA_SEGMENTO = src.LUNGHEZZA_SEGMENTO,
trg.IDENT_TESTO = src.IDENT_TESTO,
trg.RAMO_TESTO = src.RAMO_TESTO,
trg.TIPO_TESTO = src.TIPO_TESTO,
trg.COD_TESTO = src.COD_TESTO,
trg.VERSIONE_TESTO = src.VERSIONE_TESTO,
trg.DATI_TESTO = src.DATI_TESTO,
trg.PARTIZ_FASCIA_POL = src.PARTIZ_FASCIA_POL,
trg.UTENTE_INSERIMENTO =src.UTENTE_INSERIMENTO
WHERE
src.op_type = 'D'
WHEN NOT MATCHED THEN
INSERT (
NUM_POLIZZA,
COD_COMPON,
TMS_INSERIMENTO,
REVKEY,
LUNGHEZZA_SEGMENTO,
PROGR,
PROGR_SUB,
IDENT_TESTO,
RAMO_TESTO,
TIPO_TESTO,
COD_TESTO,
VERSIONE_TESTO,
DATI_TESTO,
PARTIZ_FASCIA_POL,
UTENTE_INSERIMENTO )
VALUES
(
src.NUM_POLIZZA,
src.COD_COMPON,
src.TMS_INSERIMENTO,
src.REVKEY,
src.LUNGHEZZA_SEGMENTO,
src.PROGR,
src.PROGR_SUB,
src.IDENT_TESTO,
src.RAMO_TESTO,
src.TIPO_TESTO,
src.COD_TESTO,
src.VERSIONE_TESTO,
src.DATI_TESTO,
src.PARTIZ_FASCIA_POL,
src.UTENTE_INSERIMENTO )
WHERE
src.op_type <> 'D'