Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXpZn-0003yy-Jo for pgsql-general@arkaria.postgresql.org; Tue, 26 Jun 2018 15:08:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fXpZk-0006Wh-Lb for pgsql-general@arkaria.postgresql.org; Tue, 26 Jun 2018 15:08:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXpZk-0006WY-BN for pgsql-general@lists.postgresql.org; Tue, 26 Jun 2018 15:08:12 +0000 Received: from mail-qt0-x22c.google.com ([2607:f8b0:400d:c0d::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fXpZg-0005UH-JC for pgsql-general@lists.postgresql.org; Tue, 26 Jun 2018 15:08:11 +0000 Received: by mail-qt0-x22c.google.com with SMTP id h5-v6so15405135qtm.13 for ; Tue, 26 Jun 2018 08:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=salocC72gLXHcGr+CqQc1yE26bScrLl09CD148mClxQ=; b=DyPM7vrymitq+ajEG4JntmF+GhovxoUzUWgXev4JRaBaSCFGs6SH0xc0r4jsCUxpFN KL89UYUIkYIKXHMhVQcR+ooGSwd4NW2dSuGqzpkye1o1x9eT9Epan20E/6avyM7pzcP5 imflcLFXRYYXmTAphGd7eFZgRimUr3eH/eqKo6ZxAWdnMtuVDeprHjX2XogEzNSj4MFK Vr0tVIXNzBcMz1QJ5Kj9GIVzUK3UiKWBqrrIZCPcfdyQVvBobsJmce7YnZTbHhmbkxg4 H+G9lZFLjaEy7dN7T6Zqk4bhq4qSNRdaueg9E9p3nSJC6C2wyycGyXZK+MakQohRxVVI xw6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=salocC72gLXHcGr+CqQc1yE26bScrLl09CD148mClxQ=; b=p+8/QwM281OdoEtGa0rM2RshF9eAVQTq3eQl7qYwL/p4F1hwKaGqInTutEfNL5w3In 5WnHw5fjsuqsY2/DVn1qeEcatGfUG4NdBsDd4nz/SZLOoeTXW+KzYemOP5tmWmogun+l efpuruBmOH1qyT5+4PO2drq7kKEZ6bMqorwWZbfJzQAq5gc9jAFStAhzimxfK8FP/Mrf lfgYVQQ6YdWhrMGLeympaWfQ9z6hxDUF+D7jVvJajEDfspbwdTVrHYDpXD06/QEN/6x9 yxV4a6NHlzDC30bCpzJ09Wj9OadMqtm5KywGqnpy5ylbekD2+gn4AekSsPSfuGZhDRPV /nug== X-Gm-Message-State: APt69E0YYGBSrjE0IINGfP342FGCfcK1gGyOoZHaS15+8Lm3vnqUznU4 xsmWVey+k9hld360sFPvM5llkC2nIYMXSjZJIng= X-Google-Smtp-Source: AAOMgpcRReE2JcvHFhf4NzdqTD3mNtMd0NZCFRW1W2wizr9vxk3I+0/FKkHF9hbF5XgF1AMM5UhKoq0tXfKDNYKcMmY= X-Received: by 2002:ac8:2429:: with SMTP id c38-v6mr1763724qtc.122.1530025686454; Tue, 26 Jun 2018 08:08:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:2bdb:0:0:0:0:0 with HTTP; Tue, 26 Jun 2018 08:08:05 -0700 (PDT) In-Reply-To: <8736xaseju.fsf@gmail.com> References: <95bb81dd-a80a-a493-2c3b-c03848acefc8@anayrat.info> <874lhrsugr.fsf@gmail.com> <8736xaseju.fsf@gmail.com> From: Anto Aravinth Date: Tue, 26 Jun 2018 20:38:05 +0530 Message-ID: Subject: Re: Using COPY to import large xml file To: Tim Cross Cc: Adrien Nayrat , "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000089d637056f8cdd12" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000089d637056f8cdd12 Content-Type: text/plain; charset="UTF-8" Thanks a lot everyone. After playing around with small dataset, I could able to make datasets that are easy to go with COPY. Creating datasets of around 50GB took say 2hrs (I can definitely improve on this). 54M records, COPY took around 35 minutes! Awesome.. :) :) Mean time, I understood few things like vacuum etc. Really loving postgres! Thanks, Anto. On Tue, Jun 26, 2018 at 3:40 AM, Tim Cross wrote: > > Anto Aravinth writes: > > > Thanks a lot. But I do got lot of challenges! Looks like SO data contains > > lot of tabs within itself.. So tabs delimiter didn't work for me. I > thought > > I can give a special demiliter but looks like Postrgesql copy allow only > > one character as delimiter :( > > > > Sad, I guess only way is to insert or do a through serialization of my > data > > into something that COPY can understand. > > > > The COPY command has a number of options, including setting what is used > as the delimiter - it doesn't have to be tab. You need to also look at > the logs/output to see exactly why the copy fails. > > I'd recommend first pre-processing your input data to make sure it is > 'clean' and all the fields actually match with whatever DDL you have > used to define your db tables etc. I'd then select a small subset and > try different parameters to the copy command until you get the right > combination of data format and copy definition. > > It may take some effort to get the right combination, but the result is > probably worth it given your data set size i.e. difference between hours > and days. > > -- > Tim Cross > --00000000000089d637056f8cdd12 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks a lot everyone. After playing around with small dat= aset, I could able to make datasets that are easy to go with COPY. Creating= datasets of around 50GB took say 2hrs (I can definitely improve on this).<= div>
54M records, COPY took around 35 minutes! Awesome.. :) := )

Mean time, I understood few things like vacuum e= tc.=C2=A0

Really loving postgres!=C2=A0
=
Thanks,=C2=A0
Anto.=C2=A0

On Tue, Jun 26, 2018 at 3:40 A= M, Tim Cross <theophilusx@gmail.com> wrote:

Anto Aravinth <anto.aravi= nth.cse@gmail.com> writes:

> Thanks a lot. But I do got lot of challenges! Looks like SO data conta= ins
> lot of tabs within itself.. So tabs delimiter didn't work for me. = I thought
> I can give a special demiliter but looks like Postrgesql copy allow on= ly
> one character as delimiter :(
>
> Sad, I guess only way is to insert or do a through serialization of my= data
> into something that COPY can understand.
>

The COPY command has a number of options, including setting what is = used
as the delimiter - it doesn't have to be tab. You need to also look at<= br> the logs/output to see exactly why the copy fails.

I'd recommend first pre-processing your input data to make sure it is 'clean' and all the fields actually match with whatever DDL you hav= e
used to define your db tables etc. I'd then select a small subset and try different parameters to the copy command until you get the right
combination of data format and copy definition.

It may take some effort to get the right combination, but the result is
probably worth it given your data set size i.e. difference between hours and days.

--
Tim Cross

--00000000000089d637056f8cdd12--