pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig James <craig_james@emolecules.com>
To: pgsql-performance@postgresql.org
Subject: Re: Using Between
Date: Fri, 27 Aug 2010 17:41:53 -0700
Message-ID: <4C785B51.1020105@emolecules.com> (raw)
In-Reply-To: <C3CA20D47A2DF94FBF9CF0AE8D964CC4124399@mail-001.corp.automotive.com>
References: <C3CA20D47A2DF94FBF9CF0AE8D964CC4124399@mail-001.corp.automotive.com>

On 8/27/10 5:21 PM, Ozer, Pam wrote:
> I have a query that
>
> Select Distinct VehicleId
>
>  From Vehicle
>
> Where VehicleMileage between 0 and 15000.
>
> I have an index on VehicleMileage. Is there another way to put an index on a between? The index is not being picked up. It does get picked up when I run
>
> Select Distinct VehicleId
>
>  From Vehicle
>
> Where VehicleMileage = 15000.
>
> I just want to make sure that there is not a special index I should be using.

You need to post EXPLAIN ANALYZE of your query. It could be that an index scan is actually not a good plan (for example, a sequential scan might be faster if most of your vehicles have low mileage).  Without the EXPLAIN ANALYZE, there's no way to say what's going on.

Did you ANALYZE your database after you loaded the data?

Craig

> Thanks
>
> *Pam Ozer*
>




view thread (10+ messages)  latest in thread

Message-ID: <4C785B51.1020105@emolecules.com>
Permalink:  ../4C785B51.1020105@emolecules.com/
Also on:    postgresql.org/message-id/4C785B51.1020105@emolecules.com

 · 

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: craig_james@emolecules.com
  Subject: Re: Using Between
  In-Reply-To: <4C785B51.1020105@emolecules.com>

* 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