Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XwceP-0004KK-GN for pgsql-sql@arkaria.postgresql.org; Thu, 04 Dec 2014 20:05:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XwceP-0002DC-1A for pgsql-sql@arkaria.postgresql.org; Thu, 04 Dec 2014 20:05:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XwceN-0002Cn-KL for pgsql-sql@postgresql.org; Thu, 04 Dec 2014 20:05:19 +0000 Received: from mail.fmed.uba.ar ([157.92.152.1] helo=azteca.fmed.uba.ar) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XwceI-0001v6-BH for pgsql-sql@postgresql.org; Thu, 04 Dec 2014 20:05:17 +0000 Received: from localhost (localhost [127.0.0.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id 145FE5CA0A0; Thu, 4 Dec 2014 17:04:59 -0300 (ART) X-Virus-Scanned: amavisd-new at fmed.uba.ar Received: from azteca.fmed.uba.ar ([127.0.0.1]) by localhost (azteca.fmed.uba.ar [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gbjTX-25UOs1; Thu, 4 Dec 2014 17:04:50 -0300 (ART) Received: from azteca.fmed.uba.ar (azteca.fmed.uba.ar [157.92.152.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id 87F7A5CA0A4; Thu, 4 Dec 2014 16:56:18 -0300 (ART) Date: Thu, 4 Dec 2014 16:56:18 -0300 (ART) From: Gerardo Herzig To: Tim Dudgeon Cc: pgsql-sql@postgresql.org Message-ID: <1462618385.1624233.1417722978423.JavaMail.root@fmed.uba.ar> In-Reply-To: <548064AE.4020407@gmail.com> Subject: Re: Querying with arrays MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [157.92.152.143] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Linux)/7.2.0_GA_2669) X-Pg-Spam-Score: -0.0 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org > > The plan for the query is this: > > "Seq Scan on lists (cost=0.00..16.88 rows=3 width=86) (actual > time=0.006..0.008 rows=1 loops=1)" > " Filter: (hits @> '{7}'::integer[])" > "Planning time: 0.058 ms" > "Execution time: 0.025 ms" > > What am I doing wrong? > > Tim > With so few rows to read, it is actually slower to do a index scan followed by the table scan (in order to actually read the data). Thats why it is using a seq scan. Gerardo -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql