Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j9Z31-0008Ay-RK for pgsql-admin@arkaria.postgresql.org; Wed, 04 Mar 2020 18:47:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9Z2z-0003mI-3D for pgsql-admin@arkaria.postgresql.org; Wed, 04 Mar 2020 18:47:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j9Z2x-0003m7-2p; Wed, 04 Mar 2020 18:47:08 +0000 Received: from [64.147.123.20] (helo=wout4-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9Z2p-0006cL-IY; Wed, 04 Mar 2020 18:47:05 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 29426897; Wed, 4 Mar 2020 13:46:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 04 Mar 2020 13:46:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=A iZwyvS+KbRk0ve94lKVG9wIgzNs+fC6P3w5hSvyUmU=; b=edO/lfNFr+QyaBwvH U1JCQz62Ip179NXjBrRXycCRN+KGlZnFqyjRPilSLQuPgVs3gNw3/MS0TEDyDgAd 5wDJwrlnVRPrtfS6MYnZcwTGhvaXMQ1b8Hz5Y24MGaOK6hTtcV2IIl02v/mm57ap V8X0MamSiKlLXN2nargJiPYBesv1ufngrEYl1GE+SpFGlCRiCQgGWy0Ijf6zK9po q6nbV0zyPMJIwE11lwzyI1tkDyXTZcaAjuA1Rjkdov5qtfd+LEdOtEHulM67TS2M JXOsJt5c+LjG0daMnGu4a60xty9LNyrkiFA2Ne+NKxRRkQSWwQpbwH2ynYuqxXNn AqT6A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=AiZwyvS+KbRk0ve94lKVG9wIgzNs+fC6P3w5hSvyU mU=; b=RJXU9Ag+/jOVwfdBqITIkOxgZlyPsBHKm/d0fAwfYXuPBF3K9InliJAYH vqIHhkpD7u79vlZdcsCu39Ei5e2+P85LnLhjntWK4iuRInGLJjdq+3CIO1fvyn/p aJRgF+KXjdfdHGMDl1u/lG8Zum1NwYq6es3ReEXvBxhY5zXT+ab/ya6JMvLmbGPc EyM66uiUXc46UCqHi0sJezh8Pe2yc47o6gxk7KlHGLHveN7zjpt11iN+CHlYWdQG LNBiGWuZ2+TSQjdXHIx85dSqnG+rqfhNJmGeJ80jY+s3FFv3NpX0f3KDZOLHiX1n biLh9yMCcn7tCcYMQf30S/GwihWfw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtkedguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucfkphephedtrddu leefrdduleeirddutdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from ranger.suse (50-193-196-106-static.hfc.comcastbusiness.net [50.193.196.106]) by mail.messagingengine.com (Postfix) with ESMTPA id 0BCC03280060; Wed, 4 Mar 2020 13:46:46 -0500 (EST) Subject: Re: Suggestion to reduce COPY command output to csv file To: postggen2020 s , pgsql-admin@postgresql.org, pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: Date: Wed, 4 Mar 2020 10:46:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.20 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/4/20 10:38 AM, postggen2020 s wrote: > Hi Team, > Thanks a lot all of you, for providing support peoples like me. > Could you please provide a suggestion on COPY command. > > Environment: > DB Version:9.5.15 > postgis: > Table contain GIS data. > I have a table with GIS data, its around 300MB and 2Lacks+ records. I > want to export all the records to the CSV file. I can able to export the > table data into a CSV file, but the exported CSV file size around 162MB. > While I am trying to opening the excel it is taking a long time and also > while applying vlookup excel is getting hang. > I am using below command : > \copy cities TO '/var/lib/pgsql/cities.csv' (DELIMITER ',', FORMAT > 'csv', HEADER) > I am trying to achieve the following : > 1. The exported CSV file should have within 10MB. You can select less then the entire table with a query: https://www.postgresql.org/docs/9.5/sql-copy.html query A SELECT or VALUES command whose results are to be copied. Note that parentheses are required around the query. > 2. The excel file should open quickly and able to perform vlookups > without any problems(like hang). That is something you will need to take up with MS. > Could you please provide suggestions on below queries: > 1. what I am trying to achieve, is the right assumption?. > 2. Can we use this command to use for the above use case?. > 3. Is there any tool/extension available for the above use case.? The MS Office data tools for pulling directly from database into spreadsheet via ODBC. Do you use a programming language? If so use its libraries to pull data out and into CSV or directly into a spreadsheet. > Your inputs are highly appreciated. > Regards, > Postgadm. -- Adrian Klaver adrian.klaver@aklaver.com