pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ravi Krishna <srkrishna@yahoo.com>
To: PG mailing List <pgsql-general@lists.postgresql.org>
Subject: Re: Disabling/Enabling index before bulk loading
Date: Tue, 10 Jul 2018 09:43:40 -0700
Message-ID: <97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com> (raw)
In-Reply-To: <67D408BB-5BF7-4607-A730-6F262F65811A@yahoo.com>
References: <67D408BB-5BF7-4607-A730-6F262F65811A@yahoo.com>

On 07/10/2018 07:08 AM, Ravi Krishna wrote:
> 
> We recently did a test on COPY and found that on large tables (47 million rows , 20GB of raw data) the
> difference in COPY with 16 indexes and COPY without any index is 1:14. That is, COPY is 14 times slower
> when data is ingested with all indexes as opposed to COPY first without index and then create all index.

Did you include the time to CREATE INDEX after the COPY or is the 1:14 
only for the COPY stage?

> 
> I googled for earlier posting on this and it looks like this has been asked before too.
> 
> This is what I am thinking to do:
> 
> 1 - Extract index definition and save it as a SQL somewhere, either a file or a table.
> 2 - Drop all indexes.
> 3 - Ingest data via COPY
> 4 - Recreate all indexes saved in (1).
> 
> Is there a generic sql or script or tool to accomplish (1).
> 
> thanks
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (10+ messages)  latest in thread

Message-ID: <97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com>
Permalink:  ../97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com/
Also on:    postgresql.org/message-id/97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, srkrishna@yahoo.com
  Subject: Re: Disabling/Enabling index before bulk loading
  In-Reply-To: <97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com>
  References: <67D408BB-5BF7-4607-A730-6F262F65811A@yahoo.com> <97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox