pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gregory Wood <gregw@com-stock.com>
To: Jean-Luc Lachance <jllachan@nsd.ca>
Cc: PostgreSQL-General <pgsql-general@postgresql.org>
Subject: Re: Why is it not using an index?
Date: Fri, 15 Mar 2002 15:34:46 -0500
Message-ID: <003101c1cc60$d98a70e0$7889ffcc@comstock.com> (raw)
References: <3C924680.4090806@openratings.com>
	<002801c1cc4f$25dba980$7889ffcc@comstock.com>
	<3C9258CB.B22E190A@nsd.ca>

It should be. I think the response you'll get from the people on this list
is that they're happy to accept a patch...

Greg

----- Original Message -----
From: "Jean-Luc Lachance" <jllachan@nsd.ca>
To: "Gregory Wood" <gregw@com-stock.com>
Cc: "Dmitry Tkach" <dmitry@openratings.com>; "PostgreSQL-General"
<pgsql-general@postgresql.org>
Sent: Friday, March 15, 2002 3:25 PM
Subject: Re: [GENERAL] Why is it not using an index?


> Really, the PostgreSQL interpreter should be smart enough to figure this
> out by itself...
>
>
> Gregory Wood wrote:
> >
> > > explain select * from a where x=3;
> >
> > PostgreSQL is treating 3 as an int4 (integer) type, whereas x is an int2
> > (smallint) type. Try casting the constant as a smallint and it should
use
> > the index:
> >
> > explain select * from a where x=3::smallint;
> >
> > Greg
> >
> > ----- Original Message -----
> > From: "Dmitry Tkach" <dmitry@openratings.com>
> > To: <pgsql-general@postgresql.org.pgsql-sql@postgresql.org>
> > Sent: Friday, March 15, 2002 2:07 PM
> > Subject: [GENERAL] Why is it not using an index?
> >
> > > This must be really simple, but I just can't get it :-(
> > > I have a table (a) with a single column (x):
> > >
> > >            Table "a"
> > >   Attribute |   Type   | Modifier
> > > -----------+----------+----------
> > >   x         | smallint |
> > > Index: a_idx
> > >
> > >
> > >     Index "a_idx"
> > >   Attribute |   Type
> > > -----------+----------
> > >   x         | smallint
> > > btree
> > >
> > > The table has 10000000 rows....
> > >
> > > Now, how come, when I do:
> > >
> > > explain select * from a where x=3;
> > >
> > > it says:
> > >
> > > Seq Scan on bset  (cost=100000000.00..100175934.05 rows=303 width=2)
> > >
> > > Why is it not using a_idx???
> > >
> > > I even tried set enable_seqscan to off - makes no difference :-(
> > >
> > > Any idea what is going on?
> > >
> > > Thanks a lot!
> > >
> > > Dima
> > >
> > >
> > > ---------------------------(end of
broadcast)---------------------------
> > > TIP 5: Have you checked our extensive FAQ?
> > >
> > > http://www.postgresql.org/users-lounge/docs/faq.html
> > >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




view thread (11+ messages)  latest in thread

Message-ID: <003101c1cc60$d98a70e0$7889ffcc@comstock.com>
Permalink:  ../003101c1cc60$d98a70e0$7889ffcc@comstock.com/
Also on:    postgresql.org/message-id/003101c1cc60$d98a70e0$7889ffcc@comstock.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gregw@com-stock.com, jllachan@nsd.ca, pgsql-general@postgresql.org
  Subject: Re: Why is it not using an index?
  In-Reply-To: <003101c1cc60$d98a70e0$7889ffcc@comstock.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox