Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WGvPG-0000DQ-8T for pgsql-performance@arkaria.postgresql.org; Fri, 21 Feb 2014 19:05:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WGvPF-0006zE-Oi for pgsql-performance@arkaria.postgresql.org; Fri, 21 Feb 2014 19:05:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WGvPE-0006z7-M4 for pgsql-performance@postgresql.org; Fri, 21 Feb 2014 19:05:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WGvPB-0005Hl-OI for pgsql-performance@postgresql.org; Fri, 21 Feb 2014 19:05:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s1LJ4vWE005577; Fri, 21 Feb 2014 14:04:58 -0500 From: Tom Lane To: Alexey Klyukin cc: pgsql-performance@postgresql.org Subject: Re: Lack of index usage when doing array casts In-reply-to: References: Comments: In-reply-to Alexey Klyukin message dated "Fri, 21 Feb 2014 19:01:09 +0100" Date: Fri, 21 Feb 2014 14:04:57 -0500 Message-ID: <5576.1393009497@sss.pgh.pa.us> X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Alexey Klyukin writes: > We had a problem with PostgreSQL not using an index scan in 2 similar > queries, the only difference between them is the array cast from text[] to > location_type[] (array of enum values). Hmm. IIRC the text to enum cast is considered stable not immutable, which is why that doesn't get folded to a Const on sight. However, it seems like it'd be okay for scalararraysel() to reduce stable expressions for estimation purposes, ie it should be using estimate_expression_value. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance