I have table names tb_big
with size 50 Gb. If a create an aditional column:
alter TABLE UAT_DM.ai_SUBS_MONTH_CLR ADD segment CHAR(5) not casespecific;
Everything works fine. All values are null so update will work pretty fast (1+ minutes):
update tb_big
set segment = case when LT_month <= 4 then '0'
when LT_month <= 8 then '1'
when LT_month <= 12 then '2'
when LT_month <= 17 then '3'
when LT_month <= 24 then '4'
when LT_month <= 36 then '5'
when LT_month <= 56 then '6'
when LT_month <= 83 then '7'
when LT_month <= 96 then '8'
else '9' end;
So let say I want to update it second time same column:
update tb_big
set segment = case when LT_month <= 4 then '0'
when LT_month <= 8 then '1'
when LT_month <= 12 then '2'
when LT_month <= 17 then '3'
when LT_month <= 27 then '42'
when LT_month <= 36 then '52'
when LT_month <= 56 then '6'
when LT_month <= 83 then '7'
when LT_month <= 96 then '08'
else '9' end;
Because of big table size and some unexpected TD behaviour such update will work under transaction, so every update will be logged to transient journal, which for unknown reason for me will be highly skewed (99.9%+) and take terabytes of spool. I almost put production server on knees (TD administrator didnt shutted down it and prefered it to finish and to fail to backups, because it could take long to time to roll back back. Is it true?)
My question is how to update big tables properly? My idea is to drop that column and repeat from the beginning. However I afraid I will get no more spool error (see ). A good possible solution might be creation new empty table and copying from the first table with all columns except that to be modified one. But taking x2 space isnt good practice.
Recomendation from TD administrators do not update more that 200k rows sounds ridiculous for me.
DDL of the table, which has 500 mln rows, size 50 Gb:
CREATE MULTISET TABLE UAT_DM.ai_SUBS_MONTH_CLR ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
CUST_ID DECIMAL(12,0),
LT_month DECIMAL(15,2),
days_to_LF(15,0),
REV_COM DECIMAL(18,6),
device_type VARCHAR(50) CHARACTER SET UNICODE CASESPECIFIC,
usg_qq DECIMAL(18,0),
usg_dd DECIMAL(18,6),
report_mnth CHAR(7) CHARACTER SET UNICODE NOT CASESPECIFIC,
MACN_ID DECIMAL(15,0),
segment CHAR(5) CHARACTER SET LATIN NOT CASESPECIFIC)
UNIQUE PRIMARY INDEX ( SUBS_ID ,report_mnth )
INDEX ( CUST_ID )
INDEX ( segment );