Re: Index usage on OR queries - Mailing list pgsql-general

From Tore Halvorsen
Subject Re: Index usage on OR queries
Date
Msg-id CADGw-SfxUXJNM3wN9oXNcST=u1-qvXz8nt=zS-sVOt0M2iKnjg@mail.gmail.com
Whole thread Raw
In response to Re: Index usage on OR queries  (Andy Colson <andy@squeakycode.net>)
Responses Re: Index usage on OR queries  (Andy Colson <andy@squeakycode.net>)
List pgsql-general
On Wed, Aug 31, 2011 at 4:49 PM, Andy Colson <andy@squeakycode.net> wrote:
On PG 9, after I ANALYZED the tables, it used indexes:


QUERY PLAN
---------------------------------------------------------------------------------------------------------------
 Merge Join  (cost=1.59..82778.35 rows=13171 width=20) (actual time=0.066..1076.616 rows=12966 loops=1)
  Merge Cond: (a.id = b.id)
  Join Filter: ((a."time" >= '2011-08-15 00:00:00'::timestamp without time zone) OR (b."time" >= '2011-08-01 0
  ->  Index Scan using a_pkey on a  (cost=0.00..31389.36 rows=1000000 width=12) (actual time=0.007..204.856 ro
  ->  Index Scan using b_pkey on b  (cost=0.00..31389.36 rows=1000000 width=12) (actual time=0.006..224.189 ro


ANALYZE is the magic.

You are, of course, right, but it doesn't use the TIME index.
Hmmm, may be my example isn't large enough to produce the issue.

--
Eld på åren og sol på eng gjer mannen fegen og fjåg. [Jøtul]
<demo> 2011 Tore Halvorsen || +052 0553034554

pgsql-general by date:

Previous
From: Andy Colson
Date:
Subject: Re: Index usage on OR queries
Next
From: Andy Colson
Date:
Subject: Re: Index usage on OR queries