Question about \copy

Started by John Wangabout 17 years ago3 messagesgeneral
Jump to latest
#1John Wang
johnw822003@yahoo.com

I have a table, for example, Product. It's index is Product_index.

If I use \copy to load data into the table:

\copy Product from data.txt

Will the index, Product_index, also be updated with the new data during "copy"?

Thanks.

#2Scott Marlowe
scott.marlowe@gmail.com
In reply to: John Wang (#1)
Re: Question about \copy

On Wed, Mar 11, 2009 at 11:21 AM, John Wang <johnw822003@yahoo.com> wrote:

I have a table, for example, Product. It's index is Product_index.

If I use \copy to load data into the table:

\copy Product from data.txt

Will the index, Product_index, also be updated with the new data during "copy"?

Yep.

#3F. Jovan Jester
jesterj@groupspeak.com
In reply to: John Wang (#1)
Re: Question about \copy

On Mar 11, 2009, at 1:21 PM, John Wang wrote:

I have a table, for example, Product. It's index is Product_index.

If I use \copy to load data into the table:

\copy Product from data.txt

Will the index, Product_index, also be updated with the new data
during "copy"?

Yes, and indexes are updated row by row even if bulk loading with
COPY. That's why when you're loading large amounts of data the index
updating and constraint checking can slow it down. See the manual info
on populating:

http://www.postgresql.org/docs/8.3/interactive/populate.html

-Jovan