Skip to main content
Question

Significant performance difference between COPY LOCAL and COPY FROM STDIN

  • January 15, 2020
  • 3 replies
  • 11 views

Bryan_H
Forum|alt.badge.img+2

We have a customer who is having issues with load times and observed that it took almost twice as long to COPY a file using COPY table FROM LOCAL ''; compared to piping the file to COPY table FROM STDIN;
I was able to replicate this:

dbadmin=> copy speed1090 from local '1090.txt' direct;
Time: First fetch (1 row): 822060.183 ms. All rows formatted: 822060.252 ms
[bryan@hpbox tmp]$ vsql -m disable -U dbadmin -w *** -i -c "copy speed1090 from stdin direct;" < 1090.txt
Time: First fetch (0 rows): 473844.378 ms. All rows formatted: 473844.389 ms 

Why is this the case? Also, how might SSL/TLS between client and server affect performance of COPY?

3 replies

Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • January 15, 2020

I see much worse performance when using STDIN.

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -c "\d big_local_copy;"
                                        List of Fields by Tables
 Schema |     Table      | Column |    Type     | Size | Default | Not Null | Primary Key | Foreign Key
--------+----------------+--------+-------------+------+---------+----------+-------------+-------------
 public | big_local_copy | c1     | int         |    8 |         | f        | f           |
 public | big_local_copy | c2     | varchar(10) |   10 |         | f        | f           |
 public | big_local_copy | c3     | varchar(10) |   10 |         | f        | f           |
(3 rows)

[dbadmin@SE-Sandbox-26-node1 ~]$ wc -l big.txt
8871936 big.txt

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -ic "COPY big_local_copy FROM LOCAL '/home/dbadmin/big.txt' DIRECT;"
 Rows Loaded
-------------
     8871936
(1 row)

Time: First fetch (1 row): 7459.585 ms. All rows formatted: 7459.714 ms

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -ic "COPY big_local_copy FROM STDIN DIRECT;" < /home/dbadmin/big.txt
Time: First fetch (0 rows): 24207.292 ms. All rows formatted: 24207.300 ms

Bryan_H
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • January 15, 2020

It may be file size related. My test file is 20G, comparable to what the customer loads in each batch.


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • January 15, 2020

Here is a test using a 25 GB file. It was about 14 minutes faster to use COPY LOCAL. Note that I am using Vertica 9.3.1-0 on three nodes.

[dbadmin@SE-Sandbox-26-node1 ~]$ ls -lrth /home/dbadmin/bigger.txt
-rw-r--r--. 1 dbadmin verticadba 25G Jan 15 15:51 /home/dbadmin/bigger.txt

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -c "\d bigger;"
                                    List of Fields by Tables
 Schema | Table  | Column |    Type     | Size | Default | Not Null | Primary Key | Foreign Key
--------+--------+--------+-------------+------+---------+----------+-------------+-------------
 public | bigger | c1     | varchar(80) |   80 |         | f        | f           |
 public | bigger | c2     | varchar(80) |   80 |         | f        | f           |
 public | bigger | c3     | varchar(80) |   80 |         | f        | f           |
 public | bigger | c4     | varchar(80) |   80 |         | f        | f           |
 public | bigger | c5     | varchar(80) |   80 |         | f        | f           |
 public | bigger | c6     | varchar(80) |   80 |         | f        | f           |
 public | bigger | c7     | varchar(80) |   80 |         | f        | f           |
(7 rows)

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -ic "COPY bigger FROM LOCAL '/home/dbadmin/bigger.txt' DIRECT;"
 Rows Loaded
-------------
   637880912
(1 row)

Time: First fetch (1 row): 1045943.399 ms. All rows formatted: 1045943.915 ms

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -c "TRUNCATE TABLE bigger;"
TRUNCATE TABLE

[dbadmin@SE-Sandbox-26-node1 ~]$ vsql -ic "COPY bigger FROM STDIN DIRECT;" < /home/dbadmin/bigger.txt
Time: First fetch (0 rows): 1860550.277 ms. All rows formatted: 1860550.289 ms