X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1B9E2D1B503 for ; Tue, 27 Apr 2004 09:54:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72453-02 for ; Tue, 27 Apr 2004 09:54:17 -0300 (ADT) Received: from 192.168.0.11 (fw.i-trade.hu [212.92.1.62]) by svr1.postgresql.org (Postfix) with SMTP id 98C48D1B4E6 for ; Tue, 27 Apr 2004 09:54:12 -0300 (ADT) Received: (qmail 22728 invoked from network); 27 Apr 2004 12:34:16 -0000 Received: from unknown (HELO atesz) (212.92.7.130) by 0 with SMTP; 27 Apr 2004 12:34:15 -0000 From: "Atesz" To: Subject: Re: planner/optimizer question Date: Tue, 27 Apr 2004 14:54:27 +0200 Message-ID: <002901c42c56$c8e077a0$0b02010a@atesz> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20040426171103.45600.qmail@uno.mnl.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/457 X-Sequence-Number: 6757 Hi, You should try the next queries: select support_person_id from ticket_crm_map where crm_id = 7 GROUP BY support_person_id; select support_person_id from ticket_crm_map where crm_id = 1 GROUP BY support_person_id; It can use the 'ticket_crm_map_crm_id_suppid' index. Generally the Postgres use an k-column index if columns of your conditions are prefix of the index column. For example: CREATE INDEX test_idx on test(col1,col2,col3,col4); SELECT * FROM test WHERE col1=3 AND col2=13; -- This can use the index. But the next queries cannot use the index: SELECT * FROM test WHERE col1=3 AND col3=13;. SELECT * FROM test WHERE col2=3; If you have problem with seq_scan or sort, you can disable globally and locally: SET enable_seqscan=0; SET enable_sort = 0; Regards, Antal Attila