Re: Query with multiples operators BETWEEN

From: Renaud Tthonnart <thonnart(at)amwdb(dot)u-strasbg(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, pgsql-general(at)postgresql(dot)org, peter_e(at)gmx(dot)net
Subject: Re: Query with multiples operators BETWEEN
Date: 2001-02-23 09:40:30
Message-ID: 3A96300E.E8BB5529@amwdb.u-strasbg.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:

>
> Do a VACUUM ANALYZE, for starters. These results look like the planner
> is working with the initial default estimates for a never-vacuumed table.
>
>
> Indexes might be a good idea too.
> http://www.postgresql.org/devel-corner/docs/postgres/indices.html
> has a good intro to the basics.
>
> regards, tom lane

The qwery I have problem with is always :

SELECT e.name
FROM Observation o, Exposure_EPIC e
WHERE o.numObs = e.obs
AND e.instrPN IS NOT NULL
AND o.RA BETWEEN 3 AND 5
AND o.DE BETWEEN 2 AND 7;

EXPLAIN result is :

NOTICE: QUERY PLAN:

Nested Loop (cost=0.00..56.67 rows=3 width=20)
-> Seq Scan on observation o (cost=0.00..30.00 rows=1 width=4)
-> Seq Scan on exposure_epic e (cost=0.00..22.50 rows=333 width=16)

EXPLAIN

I have created an index on columns ra and de :
CREATE INDEX ra_de_ind ON observation(ra,de);
CLUSTER ra_de_ind ON observation;
VACUUM observation;

EXPLAIN result becomes :

Nested Loop (cost=0.00..28.69 rows=3 width=20)
-> Index Scan using ra_de_ind on observation o (cost=0.00..2.03 rows=1
width=4)
-> Seq Scan on exposure_epic e (cost=0.00..22.50 rows=333 width=16)

But the qwery is always not able to find what I'm looking for.

Renaud THONNART

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Karel Zak 2001-02-23 10:05:57 Re: International support
Previous Message Louis-David Mitterrand 2001-02-23 09:23:39 UNIQUE constraint fails