From: Jodi Kanter <jkanter@virginia.edu>
To: Joe Conway <mail@joeconway.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgres Admin List <pgsql-admin@postgresql.org>
Subject: Re: indexes not being used!
Date: Fri, 21 Mar 2003 13:24:38 -0500
Message-ID: <00be01c2efd7$22814720$de138f80@virginia.edu> (raw)
References: <004101c2efc0$65e6d0a0$de138f80@virginia.edu>
<3E7B3365.5090603@joeconway.com>
<007701c2efc3$f5bed260$de138f80@virginia.edu>
<14197.1048269769@sss.pgh.pa.us>
<3E7B561E.8070805@joeconway.com>
We just finished doing this and the queries were slower with the indexes
being used. Apparently the optimizer knows what it is doing.
The root of the problem goes back to a very slow link on a web page. Of
course the programmer has stated that the problem is on the postgres side
but I have yet to find one.
Thanks
Jodi
----- Original Message -----
From: "Joe Conway" <mail@joeconway.com>
To: "Tom Lane" <tgl@sss.pgh.pa.us>
Cc: "Jodi Kanter" <jkanter@virginia.edu>; "Postgres Admin List"
<pgsql-admin@postgresql.org>
Sent: Friday, March 21, 2003 1:12 PM
Subject: Re: [ADMIN] indexes not being used!
> Tom Lane wrote:
> > Jodi Kanter <jkanter@virginia.edu> writes:
> >
> >>I apologize if this is the wrong list. I have posted explain analyzes
below.
> >
> >
> > Given the small size of the tables, I think the planner is doing the
> > right thing not to use indexes. Seqscans are probably less I/O until
> > the tables get a lot bigger.
>
> If you want to convince yourself of this, try EXPLAIN ANALYZE on your
> query with enable_seqscan set to off (discard the first result however,
> because in either case some caching will happen). For example:
>
> regression=# select * from foo;
> f0 | f1 | f2
> ----+------+-------
> 1 | cat1 | 1.21
> 2 | cat1 | 1.24
> 3 | cat1 | 1.18
> 4 | cat1 | 1.26
> 5 | cat1 | 1.15
> 6 | cat2 | 1.15
> 7 | cat2 | 1.26
> 8 | cat2 | 1.32
> 9 | cat2 | 1.3
> 10 | cat3 | 3.333
> (10 rows)
>
> regression=# VACUUM ANALYZE;
> VACUUM
> regression=# create index foo_idx on foo(f0);
> CREATE INDEX
>
> regression=# explain analyze select * from foo where f0 = 1;
> QUERY PLAN
> --------------------------------------------------------------------------
------------------
> Seq Scan on foo (cost=0.00..1.12 rows=2 width=20) (actual
> time=0.03..0.05 rows=1 loops=1)
> Filter: (f0 = 1)
> Total runtime: 0.22 msec
> (3 rows)
> regression=# set enable_seqscan to off;
> SET
> regression=# explain analyze select * from foo where f0 = 1;
> QUERY PLAN
> --------------------------------------------------------------------------
----------------------------------
> Index Scan using foo_idx on foo (cost=0.00..3.01 rows=2 width=20)
> (actual time=0.06..0.07 rows=1 loops=1)
> Index Cond: (f0 = 1)
> Total runtime: 0.20 msec
> (3 rows)
>
> regression=# set enable_seqscan to on;
> SET
> regression=# explain analyze select * from foo where f0 = 1;
> QUERY PLAN
> --------------------------------------------------------------------------
------------------
> Seq Scan on foo (cost=0.00..1.12 rows=2 width=20) (actual
> time=0.03..0.05 rows=1 loops=1)
> Filter: (f0 = 1)
> Total runtime: 0.14 msec
> (3 rows)
>
> HTH,
>
> Joe
>
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jkanter@virginia.edu, mail@joeconway.com, tgl@sss.pgh.pa.us
Subject: Re: indexes not being used!
In-Reply-To: <00be01c2efd7$22814720$de138f80@virginia.edu>
References: <004101c2efc0$65e6d0a0$de138f80@virginia.edu> <3E7B3365.5090603@joeconway.com> <007701c2efc3$f5bed260$de138f80@virginia.edu> <14197.1048269769@sss.pgh.pa.us> <3E7B561E.8070805@joeconway.com> <00be01c2efd7$22814720$de138f80@virginia.edu>
* 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