Thread: Copy faster with sorted data?

Copy faster with sorted data?

From
Denis Gasparin
Date:
Hi to all.

I'm loading 20 millions of integers in a simple table like this:

create table test(
    code integer not null primary key
);

I noticed that the time to load the integers changes if the data is
sorted before giving the copy command.

\copy test from 'codes.txt' took about 15 minutes less when codes.txt
was sorted.

I think the cause of this behaviour is index creation. Could it be?

Thank you,
Denis