Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJl9B-0001Mv-9a for pgsql-performance@arkaria.postgresql.org; Fri, 06 Feb 2015 15:48:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YJl9A-0007WH-E6 for pgsql-performance@arkaria.postgresql.org; Fri, 06 Feb 2015 15:48:44 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJl99-0007W4-GX for pgsql-performance@postgresql.org; Fri, 06 Feb 2015 15:48:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJl90-0001w0-VB for pgsql-performance@postgresql.org; Fri, 06 Feb 2015 15:48:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t16FmWf6026998; Fri, 6 Feb 2015 10:48:32 -0500 From: Tom Lane To: belal cc: pgsql-performance@postgresql.org Subject: Re: Copy command Faster than original select In-reply-to: <1423211439320-5836886.post@n5.nabble.com> References: <1423211439320-5836886.post@n5.nabble.com> Comments: In-reply-to belal message dated "Fri, 06 Feb 2015 01:30:39 -0700" Date: Fri, 06 Feb 2015 10:48:32 -0500 Message-ID: <26997.1423237712@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org belal writes: > I made complex select using PGAdmin III Query Editor, Postgre server 9.3 > select ... from mytable join .. join ... order by .... > I get [Total query runtime: 8841 ms. 43602 rows retrieved.] > but when I use > copy ([same above select]) to '/x.txt' > I get [Query returned successfully: 43602 rows affected, 683 ms execution > time.] > these test made on the same machine as the postgresql server. > can anyone explain huge difference in executing time? It's the time needed for PGAdmin to receive and display 43602 data rows, likely. PGAdmin has a reputation of not being too speedy at that. You could check this by trying some other client such as psql. Even in psql, the formatting options you use can make a very large difference in how fast it is. However, I think psql's \timing option measures just the server roundtrip time and not the time taken after that to format and display the query result. PGAdmin is probably measuring the query time differently. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance