Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id D88042E1083 for ; Fri, 11 Jan 2008 13:06:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 42424-04 for ; Fri, 11 Jan 2008 13:06:05 -0400 (AST) Received: from mailhub.ikv.de (mailhub.ikv.de [62.145.4.19]) by postgresql.org (Postfix) with ESMTP id 540CC2E34DD for ; Fri, 11 Jan 2008 13:06:06 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mailhub.ikv.de (Postfix) with ESMTP id 01A4C2FC014 for ; Fri, 11 Jan 2008 18:06:03 +0100 (CET) Received: from mailhub.ikv.de ([192.168.200.65]) by localhost (mailhub.ikv.de [192.168.200.65]) (amavisd-new, port 10024) with ESMTP id 06544-10 for ; Fri, 11 Jan 2008 18:06:03 +0100 (CET) Received: from [192.168.100.225] (unknown [192.168.100.225]) by mailhub.ikv.de (Postfix) with ESMTP id BC1482FC00E for ; Fri, 11 Jan 2008 18:06:03 +0100 (CET) Message-ID: <4787A1FB.2050808@ikv.de> Date: Fri, 11 Jan 2008 18:06:03 +0100 From: =?ISO-8859-1?Q?J=F6rg_Kiegeland?= User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Evaluating boolean formula: slow performance Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ikv.de X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200801/72 X-Sequence-Number: 28311 I have the following problem: In my table T, there are a fixed number of boolean columns, C1, .., Cn. Now, a common query is to search in this table for tuples fullfilling an arbitrary boolean condition (however only using AND and OR), e.g. SELECT * FROM T WHERE (C1 OR C2) AND (C3 OR C4 AND C5) OR C6 For every boolean column, I created an index, e.g. CREATE INDEX columnIndexForC2 ON DIM (C2); Now I did performance tests and got response times for such a query which are worser than linear response time.. However I also realized that with boolean queries which use only OR or use only AND, the response time is very fast, i.e. it seems to be constant, regardless of how many tuples I add to the table. So my question is: How can I get an acceptable response time for arbitrary boolean terms? Thanks