Re: Seq scan of table?

From: Jonathan Bartlett <johnnyb(at)eskimo(dot)com>
To: Bjorn T Johansen <btj(at)havleik(dot)no>
Cc: pgsql-general(at)postgresql(dot)org, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Seq scan of table?
Date: 2003-09-05 14:39:49
Message-ID: Pine.GSU.4.44.0309050739000.13345-100000@eskimo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

> 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.

Yes, this is correct

> 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?

Someone correct me if I'm wrong, but I believe numbers are int4's, so they
need to be cast if your column is not an int4.

Jon

>
>
> BTJ
>
> > I am trying to tune my database and I discovered one select that does a
> > seq scan on a table but I can't see why... All the join fields are indexed
> > and I am returning just one record, so no sort is done.
> > Does it just pick seq scan for the heck of it or is it a reason?
> >
> > Regards,
> >
> > BTJ
> >
> > -----------------------------------------------------------------------------------------------
> > Bjrn T Johansen (BSc,MNIF)
> > Executive Manager
> > btj(at)havleik(dot)no Havleik Consulting
> > Phone : +47 67 54 15 17 Conradisvei 4
> > Fax : +47 67 54 13 91 N-1338 Sandvika
> > Cellular : +47 926 93 298 http://www.havleik.no
> > -----------------------------------------------------------------------------------------------
> > "The stickers on the side of the box said "Supported Platforms: Windows
> > 98, Windows NT 4.0,
> > Windows 2000 or better", so clearly Linux was a supported platform."
> > -----------------------------------------------------------------------------------------------
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-09-05 14:42:19 Re: postmaster crashing
Previous Message scott.marlowe 2003-09-05 14:39:08 Re: Pagination - 1 or 2 queries?

Browse pgsql-performance by date

  From Date Subject
Next Message Patrick Hatcher 2003-09-05 15:05:00 Re: SELECT's take a long time compared to other DBMS
Previous Message Bjørn T Johansen 2003-09-05 13:23:24 Re: [PERFORM] Seq scan of table?