Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YXQnn-0000lv-0n for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Mar 2015 08:55:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YXQnl-0007v0-3J for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Mar 2015 08:55:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YXQnk-0007uj-3v for pgsql-bugs@postgresql.org; Mon, 16 Mar 2015 08:55:08 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YXQng-0000sF-3o for pgsql-bugs@postgresql.org; Mon, 16 Mar 2015 08:55:06 +0000 MIME-Version: 1.0 Subject: BUG #12871: Bug in intarray extension operators (using generic selectivity estimators instead of array oriented) To: pgsql-bugs@postgresql.org From: maxim.boguk@gmail.com Date: Mon, 16 Mar 2015 08:54:25 +0000 Message-ID: <20150316085425.2731.52467@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 12871 Logged by: Maksym Boguk Email address: maxim.boguk@gmail.com PostgreSQL version: 9.4.1 Operating system: Linux Description: As my bugreport BUG #12862 stalled in queue for unknown reason I'll try post it again. First test case showing issue: postgres=# create database test; CREATE DATABASE postgres=# \c test You are now connected to database "test" as user "postgres". test=# create table test as select array[100]::integer[] as f1 from generate_series(1,10000); SELECT 10000 test=# analyze test; ANALYZE test=# explain analyze select * from test where f1 && array[100]; QUERY PLAN --------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..532.40 rows=10000 width=25) (actual time=0.048..6.207 rows=10000 loops=1) Filter: (f1 && '{100}'::integer[]) Total runtime: 7.154 ms (3 rows) test=# create extension intarray; CREATE EXTENSION test=# explain analyze select * from test where f1 && array[100]; QUERY PLAN ------------------------------------------------------------------------------------------------------ Seq Scan on test (cost=0.00..532.40 rows=10 width=25) (actual time=0.062..5.598 rows=10000 loops=1) Filter: (f1 && '{100}'::integer[]) Total runtime: 6.548 ms (3 rows) As you could see after installing the intarray extension PostgreSQL started use a general selectivity estimator. Estimated rows=10000 before create extension and estimated rows=10 after, 10000 - correct one. Problem that custom (redefined) intarray && @> <@ operators are defined with contsel/contjoinsel instead of arraycontsel/arraycontjoinsel. However, simple change extension/intarray--1.0.sql with correct CREATE OPERATOR doesn't fix issue: test=# explain analyze select * from test where f1 && array[100]; ERROR: arraycontsel called for unrecognized operator 814221170 I cannot find any quick fix for this issue because OID of custom && operator isn't fixed, so no simple change of arraycontsel/arraycontjoinsel possible. An issue exists in any version since introducing arraycontsel/arraycontjoinsel in 9.2 up to HEAD. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs