X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AEB9E5381C for ; Thu, 21 Apr 2005 16:23:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75490-08 for ; Thu, 21 Apr 2005 19:23:48 +0000 (GMT) Received: from mail2.dbitech.ca (radius.wavefire.com [64.141.13.252]) by svr1.postgresql.org (Postfix) with SMTP id CA8A55385D for ; Thu, 21 Apr 2005 16:23:46 -0300 (ADT) Received: (qmail 6950 invoked from network); 21 Apr 2005 21:02:03 -0000 Received: from unknown (HELO ?64.141.15.12?) (64.141.15.12) by radius.wavefire.com with SMTP; 21 Apr 2005 21:02:03 -0000 From: Darcy Buskermolen Organization: Wavefire Technologies Corp To: weigelt@metux.de Subject: Re: index not used Date: Thu, 21 Apr 2005 12:23:52 -0700 User-Agent: KMail/1.7.2 Cc: postgresql performance list References: <20050421190543.GA16548@nibiru.borg.metux.de> In-Reply-To: <20050421190543.GA16548@nibiru.borg.metux.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200504211223.52612.darcy@wavefire.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/590 X-Sequence-Number: 11987 On Thursday 21 April 2005 12:05, Enrico Weigelt wrote: > Hi folks, > > > I'm doing a simple lookup in a small table by an unique id, and I'm > wondering, why explains tells me seqscan is used instead the key. > > The table looks like: > > id bigint primary key, > a varchar, > b varchar, > c varchar > > and I'm quering: select * from foo where id = 2; > > I've got only 15 records in this table, but I wanna have it as > fast as possible since its used (as a map between IDs and names) > for larger queries. The over head to load the index, fetch the record in there, then check the table for visibility and return the value, is far greater than just doing 15 compares in the original table. > > > thx -- Darcy Buskermolen Wavefire Technologies Corp. http://www.wavefire.com ph: 250.717.0200 fx: 250.763.1759