Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YI34A-0005Ne-Q6 for pgsql-performance@arkaria.postgresql.org; Sun, 01 Feb 2015 22:32:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YI349-00016l-4u for pgsql-performance@arkaria.postgresql.org; Sun, 01 Feb 2015 22:32:29 +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 1YI348-00016e-15 for pgsql-performance@postgresql.org; Sun, 01 Feb 2015 22:32:28 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YI343-00080h-TZ for pgsql-performance@postgresql.org; Sun, 01 Feb 2015 22:32:26 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id A81261281252 for ; Sun, 1 Feb 2015 14:32:23 -0800 (PST) Date: Sun, 1 Feb 2015 15:32:21 -0700 (MST) From: AlexK987 To: pgsql-performance@postgresql.org Message-ID: <1422829941197-5836319.post@n5.nabble.com> Subject: Why is GIN index slowing down my query? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.1 (/) 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 I've created a GIN index on an INT[] column, but it slows down the selects. Here is my table: create table talent(person_id INT NOT NULL, skills INT[] NOT NULL); insert into talent(person_id, skills) select generate_series, array[0, 1] || generate_series from generate_series(3, 1048575); create index talent_skills on talent using gin(skills); analyze talent; Here is my select: explain analyze select * from talent where skills <@ array[1, 15] "Bitmap Heap Scan on talent (cost=52.00..56.01 rows=1 width=37) (actual time=590.022..590.022 rows=0 loops=1)" " Recheck Cond: (skills <@ '{1,15}'::integer[])" " Rows Removed by Index Recheck: 1048573" " Heap Blocks: exact=8739" " -> Bitmap Index Scan on talent_skills (cost=0.00..52.00 rows=1 width=0) (actual time=207.661..207.661 rows=1048573 loops=1)" " Index Cond: (skills <@ '{1,15}'::integer[])" "Planning time: 1.310 ms" "Execution time: 590.078 ms" If I drop my GIN index, my select is faster: drop index talent_skills explain analyze select * from talent where skills <@ array[1, 15] "Seq Scan on talent (cost=0.00..21846.16 rows=1 width=37) (actual time=347.442..347.442 rows=0 loops=1)" " Filter: (skills <@ '{1,15}'::integer[])" " Rows Removed by Filter: 1048573" "Planning time: 0.130 ms" "Execution time: 347.470 ms" Am I missing something? -- View this message in context: http://postgresql.nabble.com/Why-is-GIN-index-slowing-down-my-query-tp5836319.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance