-2

Possible Duplicate:
syntax for COPY in postgresql

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))

How can i use copy command for this query to reduce time?

Community
  • 1
  • 1
Rafiu
  • 4,700
  • 6
  • 25
  • 27
  • Why do you post the same question twice? Didn't you like the answers you got here: http://stackoverflow.com/questions/5778005/syntax-for-copy-in-postgresql/5778503#5778503 –  Apr 25 '11 at 15:57

2 Answers2

0

COPY copies data between files and tables.

You won't reduce time using COPY.

Quassnoi
  • 413,100
  • 91
  • 616
  • 614
  • thank you. this query take more time to execute. please give me any other solution for this reduce the time. – Rafiu Apr 25 '11 at 14:14
0

COPY is used copy data between a file and a table. COPY TO is used to copy the contents of a table to a file.

If you could create the table on the fly if would by faster to use create table contacts_lists as select..., but that does not seem to be the case.

rmcc
  • 743
  • 1
  • 6
  • 14