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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brian Tarbox" <btarbox(at)theworld(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: why Sequencial Scan when selecting on primary key of table?
Date: 2003-05-31 17:13:47
Message-ID: 21073.1054401227@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"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. (Yeah, I know, it's a pain in the neck. We've had a lot of
discussions about how to fix this without breaking datatype extensibility;
no luck so far.)

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Brian Tarbox 2003-05-31 17:45:50 Re: why Sequencial Scan when selecting on primary key of table?
Previous Message Andrew Sullivan 2003-05-31 17:02:08 Re: why Sequencial Scan when selecting on primary key of table?