Re: Index usage on OR queries

From: Andy Colson <andy(at)squeakycode(dot)net>
To: Tore Halvorsen <tore(dot)halvorsen(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index usage on OR queries
Date: 2011-08-31 14:56:56
Message-ID: 4E5E4BB8.3050209@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/31/2011 9:53 AM, Tore Halvorsen wrote:
> On Wed, Aug 31, 2011 at 4:49 PM, Andy Colson <andy(at)squeakycode(dot)net
> <mailto:andy(at)squeakycode(dot)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 <http://a.id> = b.id <http://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

wow, yea.. I saw index and just assumed. Didn't even notice, sorry
about that.

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2011-08-31 15:01:28 Re: Index usage on OR queries
Previous Message Tore Halvorsen 2011-08-31 14:53:54 Re: Index usage on OR queries