配列型へのデータ移行

パフォーマンス対策の為、敢えて非正規化を行い配列型で持つ

配列型カラムの追加

alter table hoge add foo_ids intger[];

データ移行 array型でhogeテーブルに紐づくrecordを配列化する

update hoge set 
foo_ids = array( select foo_id from foo f where f.hoge_id = hoge.hoge_id )

selectする時は

select * from hoge where 1 = ANY( foo_ids ) 

または

select * from hoge where foo_ids && '{1}' 

のような感じにする予定。