-- Mirror registration time on db_users_d for analytics without joining db_users_a
ALTER TABLE db_users_d
    ADD COLUMN date_reg INT NOT NULL DEFAULT 0 COMMENT 'Registration unix time (seconds); same as db_users_a.date_reg' AFTER screen_name;

UPDATE db_users_d d
INNER JOIN db_users_a a ON a.id = d.id
SET d.date_reg = a.date_reg;

CREATE INDEX idx_users_d_date_reg ON db_users_d (date_reg);
