Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D81BF16D90FA for ; Tue, 27 Mar 2012 17:58:52 -0300 (ADT) Received: from news.hub.org ([200.46.204.72]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SCdTe-0008Bi-OE for pgsql-performance@postgresql.org; Tue, 27 Mar 2012 20:58:51 +0000 Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id q2RKwb2c007884 for ; Tue, 27 Mar 2012 17:58:37 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id q2RKbwHb092469 for pgsql-performance@postgresql.org; Tue, 27 Mar 2012 17:37:58 -0300 (ADT) (envelope-from news) From: Francois Deliege X-Newsgroups: pgsql.performance Subject: Distinct + Limit Date: Tue, 27 Mar 2012 13:37:51 -0700 (PDT) Organization: http://groups.google.com Lines: 14 Message-ID: <5833589.541.1332880671745.JavaMail.geo-discussion-forums@pbbnv8> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Complaints-To: groups-abuse@google.com Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.38.213.178; posting-account=MBeVbAoAAAArGxjJOpuhEJ6gPEjWX8_H User-Agent: G2/1.0 To: pgsql-performance@postgresql.org X-Pg-Spam-Score: -0.5 (/) X-Archive-Number: 201203/172 X-Sequence-Number: 46622 Hi group, I have the following table with millions of rows CREATE TABLE table1 ( col1 text, col1 text, doc text ) select col1 from table1 group by col1 limit 2; select distinct on (col1) col1 from table1 limit 2;