Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C6D6D9FA38F for ; Thu, 26 Oct 2006 18:53:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 48998-03 for ; Thu, 26 Oct 2006 18:53:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 4B18E9F944D for ; Thu, 26 Oct 2006 18:53:14 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k9QLrBYo026067; Thu, 26 Oct 2006 17:53:11 -0400 (EDT) To: "Tom Darci" cc: pgsql-performance@postgresql.org Subject: Re: query slows down drastically with increased number of fields In-reply-to: <6FB011BE26AACD4CB5F2B505AE0BEB2E020B6E86@MI8NYCMAIL05.Mi8.com> References: <6FB011BE26AACD4CB5F2B505AE0BEB2E020B6E86@MI8NYCMAIL05.Mi8.com> Comments: In-reply-to "Tom Darci" message dated "Wed, 25 Oct 2006 13:20:42 -0400" Date: Thu, 26 Oct 2006 17:53:10 -0400 Message-ID: <26066.1161899590@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.125 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200610/565 X-Sequence-Number: 21694 "Tom Darci" writes: > It runs in about half a second (running in PgAdmin... the query run > time, not the data retrieval time) I don't have a lot of faith in PgAdmin's ability to distinguish the two. In fact, for a query such as you have here that's just a bare seqscan, it's arguably *all* data retrieval time --- the backend will start emitting records almost instantly. FWIW, in attempting to duplicate your test I get regression=# explain analyze select f1 from foo; QUERY PLAN ------------------------------------------------------------------------------------------------------------ Seq Scan on foo (cost=0.00..1541.00 rows=100000 width=4) (actual time=0.161..487.192 rows=100000 loops=1) Total runtime: 865.454 ms (2 rows) regression=# explain analyze select f1,f1,f1,f1,f1,f1,f1,f1,f1,f1,f1 from foo; QUERY PLAN ------------------------------------------------------------------------------------------------------------ Seq Scan on foo (cost=0.00..1541.00 rows=100000 width=4) (actual time=0.169..603.795 rows=100000 loops=1) Total runtime: 984.124 ms (2 rows) Note that this test doesn't perform conversion of the field values to text form, so it's an underestimate of the total time spent by the backend for the real query. But I think almost certainly, your speed difference is all about having to send more values to the client. The costs not measured by the explain-analyze scenario would scale darn near linearly with the number of repetitions of f1. regards, tom lane