Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 7C702633130 for ; Mon, 21 Dec 2009 18:19:53 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 56330-04-7 for ; Mon, 21 Dec 2009 22:19:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.26]) by mail.postgresql.org (Postfix) with ESMTP id 5B59B63387D for ; Mon, 21 Dec 2009 18:16:00 -0400 (AST) Received: by qw-out-2122.google.com with SMTP id 9so1072472qwb.61 for ; Mon, 21 Dec 2009 14:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=7HZKsa8BzaMp8kagrDwEw6aDrKW21MaQyP+R6LLmGhI=; b=gtsbrb7DpdjYv7BeYDAbIjhSTCR78ukNs63yKnHO1vYm0EarD4L667VFkaxnLcn8yI Nq+az+9sX0uZUZhvjEUNd7IiZ9/hrqDrivX9jphyUH46AaU/SN+ALoaykS/ZPMW7LHRv rh7y98hk2/b7Ds/jtWx1drLtnpQVZe8RdTsl4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=qBFTCVH4TSZyrLQY5SJo1L8bvXEQDB3lxKNsxjt/kcJsDew4a0OEsk8KkNafnrRlGN ajSF6zcdEm8MHFuvgSDCWvSUq0HnVoxsl0Swjl+wJ+fD2lorZsp5M5GXqndn7mTjn2cI Gy3/eM0Snl1ezrsAC5nbUo6cXbbthI2wYTq/A= MIME-Version: 1.0 Received: by 10.229.111.77 with SMTP id r13mr3008764qcp.85.1261433758701; Mon, 21 Dec 2009 14:15:58 -0800 (PST) Date: Mon, 21 Dec 2009 17:15:58 -0500 Message-ID: <302670f20912211415n4fc73b04x19eebfb9ff0acd60@mail.gmail.com> Subject: 8.4.1 distinct query WITHOUT order by From: Gary Chambers To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/48 X-Sequence-Number: 33486 All... One of the groups where I work uses a homegrown C/C++ application that was written back in 7.3 days which is now running on an 8.4.1 server (which, until very recently, was running on an 8.1 server). Unfortunately, they did not use an order by in the query and are now dealing with a return dataset that is unsorted and difficult to use. The current maintainer is unsure about being able to do the right thing and recompile the code after fixing the query. Aside from disabling enable_hashagg (which, according to the documentation, is performance-expensive), what other options do I have? What are the ramifications of renaming the table (containing 8000 rows) and creating a view of the same name? Assuming it's possible, would the efficiency of a rule to rewrite the query be an acceptable alternative? Thanks in advance for any insight and suggestions! -- Gary Chambers /* Nothing fancy and nothing Microsoft! */