i've got 2 tables in postgres:
sources [id, term, type] posts [id, source_id, message, term, type]
i'm de-normalizing data, i'm adding term , type columns each of posts, , getting rid of sources table.
is there way fast query update posts each of respective sources data (there 8 million posts).
something like:
update posts join sources on posts.source_id = sources.id set post.term = sources.term, posts.term_type = sources.term_type;
but throwing syntax error me.
the correct syntax in postgres is:
update posts set posts.source = sources.source, post.term = sources.term, posts.term_type = sources.term_type sources posts.source_id = sources.id;
or, can use row constructor:
update posts set (source, term, term_type) = (select s.source, s.term, s.term_type source s posts.source_id = s.id );
Comments
Post a Comment