-2

可能重复:
postgresql 中 COPY 的语法

INSERT INTO contacts_lists (contact_id, list_id)
          SELECT contact_id, 67544
          FROM plain_contacts
          WHERE TRUE
                AND is_print = TRUE  AND TRUE  AND (NOT EXISTS (select title_id from company_types_lists_titles where company_types_list_id = 55321) OR title_id in (select title_id from company_types_lists_titles where company_types_list_id = 55321))             AND company_type_id = 7
            AND country_id IN (select country_id from countries_lists WHERE list_id = 67544)
                  AND ((state_id IS NULL OR country_id NOT IN (231,39) OR state_id IN (SELECT state_id FROM lists_states WHERE list_id = 67544))
        OR zone_ids && ARRAY(SELECT zone_id FROM lists_zones WHERE list_id = 67544)
      )

            AND (NOT EXISTS (select award_id from company_types_lists_top_awards where company_types_list_id = 55321) OR top_award_ids && ARRAY(select award_id from company_types_lists_top_awards where company_types_list_id = 55321))

我如何使用复制命令进行此查询以减少时间?

4

2 回答 2

0

COPY在文件和表之间复制数据。

您不会减少使用COPY.

于 2011-04-25T14:11:02.280 回答
0

COPY用于在文件和表之间复制数据。COPY TO用于将表的内容复制到文件中。

如果您可以即时创建表,那么使用起来会更快create table contacts_lists as select...,但情况似乎并非如此。

于 2011-04-28T15:10:13.733 回答