Re: why Sequencial Scan when selecting on primary key of table?

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brian Tarbox <btarbox(at)theworld(dot)com>, Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: why Sequencial Scan when selecting on primary key of table?
Date: 2003-05-31 17:51:11
Message-ID: 1054403470.11968.34.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sat, 2003-05-31 at 13:13, Tom Lane wrote:
> "Brian Tarbox" <btarbox(at)theworld(dot)com> writes:
> > When I say "explain select * from Patient where Patient_primary_key = 100"
> > I get sequential scan.
>
> Perhaps Patient_primary_key is not an integer field? If not, you need
> to cast the constant 100 to the right type. Or write '100' with
> single quotes around it, which leaves Postgres to choose the constant's
> datatype.

Out of curiosity, why don't we confirm the unquoted value is an integer,
numeric, etc, then change it into type 'unknown'? From that point
forward it would be treated like it's quoted counterpart.

Is this noticeably slower or am I missing something?

--
Rod Taylor <rbt(at)rbt(dot)ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2003-05-31 17:55:01 Re: why Sequencial Scan when selecting on primary key of table?
Previous Message Brian Tarbox 2003-05-31 17:45:50 Re: why Sequencial Scan when selecting on primary key of table?