X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 73A9656397 for ; Wed, 2 Mar 2005 17:52:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42361-01 for ; Wed, 2 Mar 2005 17:52:12 +0000 (GMT) Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) by svr1.postgresql.org (Postfix) with ESMTP id 2E22E56385 for ; Wed, 2 Mar 2005 17:52:11 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Performance tradeoff Date: Wed, 2 Mar 2005 12:52:10 -0500 Message-ID: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Performance tradeoff Thread-Index: AcUfUI7zBX13LqSSSYKqa+nvfysjMw== From: "Shawn Chisholm" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/31 X-Sequence-Number: 10736 Hi All, I am wondering about the relative performance of "insert into table1 = select distinct a,b from ..." and "insert into table1 select a,b from = ... group by a,b" when querying tables of different sizes (10K, 100K, = 1s, 10s, 100s of millions of rows). =20 The distinct way tends to sort/unique and the group by tends to hash = aggregate... any opinions on which is better? I can also change the schema to a certain extent, so would it be = worthwhile to put indices on the queried tables (or refactor them) = hoping the distinct does an index scan instead of sort... would the = query planner take advantage of that? Thanks, Shawn