Re: The old "not using index" question

From: "Jan-Philipp 'Thefly' Reining" <jpr(at)turtle-entertainment(dot)de>
To: <depesz(at)depesz(dot)pl>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: The old "not using index" question
Date: 2002-12-02 12:56:30
Message-ID: 045801c29a02$3c6f3b90$84c206d4@thefly
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

> show us explain analyze output.

Here we go:

---this one is using the index on "ranking"
SELECT *
FROM ttm_slots s
WHERE s.peering = 72
AND s.ranking = 1050

explain:
Index Scan using ranking_ttm_slots_key on ttm_slots s (cost=0.00..191.06
rows=8 width=62)

---but this one does not?
SELECT *
FROM ttm_slots s
WHERE s.peering = 72
AND s.ranking < 1050
AND s.ranking > 950

explain:
Seq Scan on ttm_slots s (cost=0.00..1823.64 rows=7949 width=62)

The index ist "btree", so it should be able to use the index with a < >
comparison?

\d ranking_ttm_slots_key
Index "ranking_ttm_slots_key"
Column | Type
---------+---------
ranking | integer
btree

regards,

// Jan-Philipp 'Thefly' Reining

----- Original Message -----
From: "Hubert depesz Lubaczewski" <depesz(at)depesz(dot)pl>
To: "Jan-Philipp 'Thefly' Reining" <jpr(at)turtle-entertainment(dot)de>;
<pgsql-general(at)postgresql(dot)org>
Sent: Saturday, November 30, 2002 1:20 AM
Subject: Re: [GENERAL] The old "not using index" question

> On Fri, Nov 29, 2002 at 05:37:04PM +0100, Jan-Philipp 'Thefly' Reining
wrote:
> > ---but this one does not?
> > SELECT *
> > FROM ttm_slots s
> > WHERE s.peering = 72
> > AND s.ranking < 1050
> > AND s.ranking > 950
> >
> > The index ist "btree", so it should be able to use the index with a < >
> > comparison?
>
> show us explain analyze output.
> probably planner thinks there are too many rows matching this criteria
> to use index.
>
> depesz
>
> --
> hubert depesz lubaczewski http://www.depesz.pl/
> ------------------------------------------------------------------------
> Mój Boże, spraw abym milczał, dopóki się nie upewnię, że naprawdę mam
> coś do powiedzenia. (c) 1998 depesz
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Prasanna Phadke 2002-12-02 13:00:34 Re: 7.4 Wishlist
Previous Message Shridhar Daithankar 2002-12-02 11:28:52 Re: [GENERAL] One SQL to access two databases.