X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 6FAFF9DCDD4 for ; Fri, 3 Mar 2006 03:37:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87471-02 for ; Fri, 3 Mar 2006 03:37:56 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from loki.globexplorer.com (loki.globexplorer.com [12.25.176.46]) by postgresql.org (Postfix) with ESMTP id E0BAF9DCDD3 for ; Fri, 3 Mar 2006 03:37:53 -0400 (AST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Subject: Re: Sequential scan where Index scan expected (update) Date: Thu, 2 Mar 2006 23:37:53 -0800 Message-ID: <71E37EF6B7DCC1499CEA0316A2568328024BC055@loki.wc.globexplorer.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Sequential scan where Index scan expected (update) Thread-Index: AcY+lCvOSnRYfeDrQ+i6d7mK9cnQewAAGQwE From: "Gregory S. Williamson" To: "Bryce Nesbitt" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] X-Spam-Score: 0.09 X-Spam-Level: X-Archive-Number: 200603/60 X-Sequence-Number: 24406 Perhaps it is clogged with dead tuples -- has it been vacuumed recently = with enough FSM space ? It seems unlikely but maybe try an explict cast for the thing_id call, = e.g. explain update xx_thing_event set thing_color=3D'foo' where thing_event_id=3D10000::bigint; It may also be that 5842 rows is enough that the planner decides it is = faster to do a sequential scan that the busier index scan (read index, = get data row, versus just reading all the necessary pages in one faster = sequential scan). If you set the sequential scan parameter in the config file and reload = postgres does the same query get faster ? (not suggesting this for real = runtime use but it can be useful to diagnose issues). Greg Williamson DBA GlobeXplorer LLC -----Original Message----- From: pgsql-sql-owner@postgresql.org on behalf of Bryce Nesbitt Sent: Thu 3/2/2006 11:28 PM To: pgsql-sql@postgresql.org Cc:=09 Subject: [SQL] Sequential scan where Index scan expected (update) I'm getting sequential scans (and poor performance), on scans using my primary keys. This is an older postgres. Can anyone help figure out why? demo=3D# \d xx_thing Table "public.xx_thing" Column | Type | Modifiers -------------------------+-----------------------------+----------- thing_id | bigint | not null thing_model | character varying(128) | thing_color | character varying(128) | thing_year | integer | Indexes: "xx_thing_pkey" primary key, btree (thing_id) demo=3D# analyze verbose xx_thing_event; INFO: analyzing "public.xx_thing_event" INFO: "xx_thing_event": 3374 pages, 3000 rows sampled, 197478 estimated total rows demo=3D# explain update xx_thing_event set thing_color=3D'foo' where thing_event_id=3D10000; QUERY PLAN --------------------------------------------------------------------- Seq Scan on xx_thing_event (cost=3D0.00..5842.48 rows=3D1 width=3D110) Filter: (thing_event_id =3D 10000) (2 rows) demo=3D# select * from version(); version -------------------------------------------------------------------------= --------------------------------- PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20) (1 row) ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly !DSPAM:4407f048253644359117518!