pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrei Bintintan <klodoma@ar-sd.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index not used in query. Why?
Date: Tue, 19 Oct 2004 12:52:49 -0400
Message-ID: <16865.1098204769@sss.pgh.pa.us> (raw)
In-Reply-To: <0bef01c4b5f8$70026ae0$0b00a8c0@forge>
References: <0bef01c4b5f8$70026ae0$0b00a8c0@forge>

"Andrei Bintintan" <klodoma@ar-sd.net> writes:
> Hi to all! I have the following query. The execution time is very big, it
> doesn't use the indexes and I don't understand why...

Indexes are not necessarily the best way to do a large join.

> If I use the following query the indexes are used:

The key reason this wins seems to be that the id_status = 4 condition
is far more selective than id_status > 3 (the estimates are 52 and 36967
rows respectively ... is that accurate?) which means that the second
query is inherently about 1/700th as much work.  This, and not the use
of indexes, is the fundamental reason why it's faster.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <16865.1098204769@sss.pgh.pa.us>
Permalink:  ../16865.1098204769@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16865.1098204769@sss.pgh.pa.us

 · 

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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, klodoma@ar-sd.net
  Subject: Re: Index not used in query. Why?
  In-Reply-To: <16865.1098204769@sss.pgh.pa.us>

* 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