postgresql - query optimization -
i have 50964218 records in table. going fetch data table , insert same table. takes more time manipulate. how optimize query.
the query
insert contacts_lists (contact_id, list_id, is_excluded, added_by_search) select contact_id, 68114 , true, added_by_search contacts_lists cl1 list_id = 67579 , is_excluded = true , not exists (select 1 contacts_lists cl2 cl1.contact_id = cl2.contact_id , cl2.list_id = 68114 )
index: list_id,contact_id
you better results left join:
select t1.[field], ... t1 left join t2 on [conditions] t2.[any pkey field] null;
Comments
Post a Comment