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 1fXZh8-00058Q-SI for pgsql-general@arkaria.postgresql.org; Mon, 25 Jun 2018 22:10:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fXZh3-0004TI-EZ for pgsql-general@arkaria.postgresql.org; Mon, 25 Jun 2018 22:10:41 +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 1fXZh3-0004T2-4f for pgsql-general@lists.postgresql.org; Mon, 25 Jun 2018 22:10:41 +0000 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fXZgz-0006g6-HO for pgsql-general@lists.postgresql.org; Mon, 25 Jun 2018 22:10:40 +0000 Received: by mail-pg0-x230.google.com with SMTP id q14-v6so2897408pgt.13 for ; Mon, 25 Jun 2018 15:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=gRh60huq9likWCq324saNkQndJy0FQS4cQTwzCZ1V2w=; b=K5ZJSZgxi0Af7/oejl3FQ8aBiF1D3lzhrEy17cXkLHgYUteQ38RxbHNHwtytJ531L1 dzXdWqlIzUpKQ1VfGphmF0p+fAiRcb1u09Tyv0xWSS0zXOAV19Ony8/6CeImOPmHJG/9 wfen16PrnvPJbZe5ilKvmAp/A9mbn2d4a+zYeUgdp9sTAz7AqW6MqSMxvFXp6jxdrk2P LdFyaMDEJTn6NBTQ67GAPBiPF682RMkF6zc23CnYWL2PX2Vfx43xNvv6u2T+EYNraNmn U8G2Aq8rkJgoqqoPdwJmJtSH5lKba6siMUq7XwPVIN4hfTENr2KpUQG9IQdEFnghloCg efAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=gRh60huq9likWCq324saNkQndJy0FQS4cQTwzCZ1V2w=; b=S2fx0pv7tncmuOn9p/MNKbAQRudMLEmJBsit8roCofiNn22zA+wZNDXny+ZaQGOma/ c8/h1Zz9XZdYCzXOsy43in91itpbYD1G10Qso6/h10mFOjPfwUPzEgilf5kV7XQ+hd+G qaFfM1cSINnW5USJWvtvgCHOPCOR9AeqmjULcPkdZH10/iINQMn88JuNMM8kYeNW2jFs JU1pUfXtSNwvIja+TtvcTlnk4kM+J2TEV9YXzOtMy2Lbl5XKEUAZnm7dp8QuMTael1qS +EWvhvd0CjmhBHLqophMyxg2HeewrzcN2N6lo2VyWgyuhn51UTKLv6urakms9UGkJAa5 2G5w== X-Gm-Message-State: APt69E3xDUzImXUGXSEIfAOAHz/2mLI0ZUgFrCueN9Y0UE/IJemKKkxk j2+bQAI7Vqy/81TZ/24pkmi+0AhB X-Google-Smtp-Source: ADUXVKIEm85d5PVCDPQRXW9Z28i03cIg75WM3Zfo93AyXOqU9PltEwr+lfGBokBY9Ow64DGWKs66Zg== X-Received: by 2002:a62:a50e:: with SMTP id v14-v6mr11079861pfm.121.1529964634896; Mon, 25 Jun 2018 15:10:34 -0700 (PDT) Received: from tim-desktop (2001-44b8-31f2-bb00-6973-e10d-82ca-6fb2.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:6973:e10d:82ca:6fb2]) by smtp.gmail.com with ESMTPSA id h13-v6sm28038pgp.13.2018.06.25.15.10.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 15:10:34 -0700 (PDT) References: <95bb81dd-a80a-a493-2c3b-c03848acefc8@anayrat.info> <874lhrsugr.fsf@gmail.com> User-agent: mu4e 0.9.18; emacs 26.1 From: Tim Cross To: Anto Aravinth Cc: Adrien Nayrat , "pgsql-generallists.postgresql.org" Subject: Re: Using COPY to import large xml file In-reply-to: Date: Tue, 26 Jun 2018 08:10:29 +1000 Message-ID: <8736xaseju.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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