| PostgreSQL Reference Manual - Volume 1 - SQL Language Reference by The PostgreSQL Global Development Group Paperback (6"x9"), 716 pages ISBN 0954612027 RRP £32.00 ($49.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
11.4.2 Use COPY
Use COPY to load
all the rows in one command, instead of using a series of
INSERT commands. The COPY
command is optimized for loading large numbers of rows; it is less
flexible than INSERT, but incurs significantly
less overhead for large data loads. Since COPY
is a single command, there is no need to disable autocommit if you
use this method to populate a table.
If you cannot use COPY, it may help to use PREPARE to create a
prepared INSERT statement, and then use
EXECUTE as many times as required. This avoids
some of the overhead of repeatedly parsing and planning
INSERT.
Note that loading a large number of rows using
COPY is almost always faster than using
INSERT, even if PREPARE is used and
multiple insertions are batched into a single transaction.
| ISBN 0954612027 | PostgreSQL Reference Manual - Volume 1 - SQL Language Reference | See the print edition |