Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 068FF9FB95F for ; Tue, 20 Feb 2007 18:12:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 13926-02 for ; Tue, 20 Feb 2007 18:12:37 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from weatherbeeta.com.au (218-214-212-153.people.net.au [218.214.212.153]) by postgresql.org (Postfix) with SMTP id DCDE59FBA56 for ; Tue, 20 Feb 2007 18:12:30 -0400 (AST) Received: (qmail 10640 invoked from network); 20 Feb 2007 22:12:28 -0000 X-NetworkBox-HamSign: 0101;OUT;wbeetaau1;c96bac90ff672a513f14c3caf161a780; Received: from mail.weatherbeeta.com.au (10.10.0.2) by network-box.weatherbeeta.com.au with SMTP; 20 Feb 2007 22:12:27 -0000 Received: (qmail 13493 invoked by uid 1166); 21 Feb 2007 09:12:27 +1100 Received: from 172.20.0.155 by mail.weatherbeeta.com.au (envelope-from , uid 1165) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.6/2315. perlscan: 1.25-st-qms. Clear:RC:1(172.20.0.155):. Processed in 0.298802 secs); 20 Feb 2007 22:12:27 -0000 X-Antivirus-mail.weatherbeeta.com.au-Mail-From: phillip.smith@weatherbeeta.com.au via mail.weatherbeeta.com.au X-Antivirus-mail.weatherbeeta.com.au: 1.25-st-qms (Clear:RC:1(172.20.0.155):. Processed in 0.298802 secs Process 13482) Received: from it-phil.weatherbeeta.com.au (HELO wbaus090) (172.20.0.155) by mail.weatherbeeta.com.au with SMTP; 21 Feb 2007 09:12:25 +1100 From: "Phillip Smith" To: =?iso-8859-1?Q?'Marcin_St=EApnicki'?= , Subject: Re: DISTINCT ON not working...? Date: Wed, 21 Feb 2007 09:12:24 +1100 Organization: Weatherbeeta Pty Ptd Message-ID: <000e01c7553c$3319b530$9b0014ac@wbaus090> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Scanned-By-wbeetaau1: Virus scan performed by network-box X-Scanned-By-wbeetaau1: Scanner file id is wbeetaau1-1172009547.998-10632-000 X-Scanned-By-wbeetaau1: No known viruses found in message (received+scanned in 0.02/0.07 secs) X-Scanned-By-wbeetaau1: Spam-Check-Result: No, hits=0 required=7 tests= autolearn=no version=2.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/210 X-Sequence-Number: 27544 This is a temporary table (with no indexes) that gets created in the = same transaction block as the SELECT gets run, but I tried creating an index = on the ean column anyway with no luck: CREATE INDEX ean_idx ON TMPTABLE USING btree (ean); SELECT DISTINCT ON (ean) ean, count(*) FROM TMPTABLE WHERE code NOT IN (SELECT code FROM stock_deleted) AND ean IS NOT NULL GROUP BY ean; Still returns: 3246576919422 2 -----Original Message----- From: pgsql-sql-owner@postgresql.org = [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Marcin St=EApnicki Sent: Tuesday, 20 February 2007 23:34 To: pgsql-sql@postgresql.org Subject: Re: [SQL] DISTINCT ON not working...? Wild guess - have you tried reindexing this table? I haven't seen corrupted indexes since 7.1, though - it usually means subtle hardware problems. *******************Confidentiality and Privilege Notice******************* The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email. Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments