Main Table:
CREATE TABLE ca_ger.cln_trans_base (
store_code VARCHAR(25),
year_week varchar(25),
division VARCHAR(25) encode lzo,
market_share_code VARCHAR(25) encode bytedict,
pon VARCHAR(25) encode lzo,
osp_price REAL encode bytedict
)
diststyle key distkey(store_code)
sortkey(store_code,year_week);
COMMIT;
Second table:
CREATE TABLE ca_ger.divisions(
store_code VARCHAR(25),
year_week varchar(25),
division VARCHAR(25) encode lzo
)
diststyle key distkey(store_code)
sortkey(store_code,year_week);
COMMIT;
alter table ca_ger.cln_Trans_base
add column division(varchar 25);
Join clause:
update ca_ger.cln_trans_base
set division=b.division
from ca_Ger.cln_trans_base a
join divisions b on a.year_week=b.year_week;
After this, I ran vacuum
and analyze
. After this, I checked stats table and rows are doubled.