Search Postgresql Archives

Re: question on error during COPY FROM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Aug 23, 2016 at 6:04 AM, Jerome Wagner <jerome.wagner@xxxxxxxxxxx> wrote:
Hello,

in the documentation I read


COPY stops operation at the first error. This should not lead to problems in the event of a COPY TO, but the target table will already have received earlier rows in a COPY FROM. These rows will not be visible or accessible, but they still occupy disk space. This might amount to a considerable amount of wasted disk space if the failure happened well into a large copy operation. You might wish to invoke VACUUM to recover the wasted space.

does that mean that I should always execute a VACUUM to recover the wasted space when an error is triggered or will the auto-vacuum mechanism do the job by itself ?

Thanks
Jerome

>but the target table will already have received earlier rows in a COPY FROM
No, that is not what happens. The entire copy is not permanently written to disk until a COMMIT or the entire statement is completed (;). On first error, a ROLLBACK is done so there is no wasted space. That being said, it is always good practice to schedule a VACUUM ANALYZE (but not FULL) in the off hours to insure a cleanup and fresh statistics.


--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux