syntax for COPY in postgresql

笑着哭i 提交于 2019-12-01 14:51:25

As your rows are already in the database (because you apparently can SELECT them), then using COPY will not increase the speed in any way.

To be able to use COPY you have to first write the values into a text file, which is then read into the database. But if you can SELECT them, writing to a textfile is a completely unnecessary step and will slow down your insert, not increase its speed

Your statement is as fast as it gets. The only thing that might speed it up (apart from buying a faster harddisk) is to remove any potential index on contact_lists that contains the column contact_id or list_id and re-create the index once the insert is finished.

You can find the syntax described in many places, I'm sure. One of those is this wiki article.

It looks like it would basically be:

COPY plain_contacts (contact_id, 67544) TO some_file

And

COPY contacts_lists (contact_id, list_id) FROM some_file

But I'm just reading from the resources that Google turned up. Give it a try and post back if you need help with a specific problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!