Re: [PERFORM] Seq scan of table?

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Bjorn T Johansen" <btj(at)havleik(dot)no>, pgsql-general(at)postgresql(dot)org
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] Seq scan of table?
Date: 2003-09-05 10:07:12
Message-ID: 200309051107.12756.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

On Friday 05 September 2003 09:47, Bjorn T Johansen wrote:
> I think I have found out why.. I have a where clause on a ID field but it
> seems like I need to cast this integer to the same integer as the field is
> defined in the table, else it will do a tablescan.
>
> Is this assumtion correct? And if it is, do I then need to change all my
> sql's to cast the where clause where I just have a number (eg where field
> = 1) to force the planner to use index scan instead of seq scan?

PG's parser will assume an explicit number is an int4 - if you need an int8
etc you'll need to cast it, yes.
You should find plenty of discussion of why in the archives, but the short
reason is that PG's type structure is quite flexible which means it can't
afford to make too many assumptions.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Suleymanov 2003-09-05 10:11:29 default EXECUTE privilege
Previous Message Peter Childs 2003-09-05 10:06:23 Re: Replaceing records

Browse pgsql-performance by date

  From Date Subject
Next Message Bjørn T Johansen 2003-09-05 13:23:24 Re: [PERFORM] Seq scan of table?
Previous Message Bjorn T Johansen 2003-09-05 08:47:54 Re: Seq scan of table?