How improve such query? - Mailing list pgsql-sql

From Remigiusz Sokolowski
Subject How improve such query?
Date
Msg-id Pine.GS4.4.02A.9909161310290.23956-100000@netra.gdansk.sprint.pl
Whole thread Raw
List pgsql-sql
hi!
I have a table about following structure
Table    = crs
+-------------------------------+--------------------------------+-------+
|             Field             |            Type                | Length|
+-------------------------------+--------------------------------+-------+
| crs_stop                      | char()                         |    32 |
| crs_dir                       | char()                         |    32 |
| crs_time                      | int4                           |     4 |
| crs_opt                       | char()                         |     3 |
+-------------------------------+--------------------------------+-------+
Index:    crs1_idx

and need speed up following query:
SELECT * FROM crs c1 WHERE c1.crs_stop='_some_stop' AND
c1.crs_dir='some_direction' ORDER BY c1.crs_time;

I built index:

+-----------------------------+----------------------------------+-------+
|         Field               |              Type                | Length|
+-----------------------------+----------------------------------+-------+
| crs_stop                    | char()                           |    32 |
| crs_dir                     | char()                           |    32 |
+-----------------------------+----------------------------------+-------+
but 

EXPLAIN SELECT * FROM crs c1 WHERE c1.crs_stop='_some_stop' AND
c1.crs_dir='some_direction' ORDER BY c1.crs_time;
shows following:

NOTICE:  QUERY PLAN:

Sort  (cost=160.92 rows=1 width=40) ->  Seq Scan on crs c1  (cost=160.92 rows=1 width=40)

EXPLAIN

so it doesn't use index.
What am I doing wrong?
Thanks in advanceRem

-- 

-------------------------------------------------------------------*------------
Remigiusz Sokolowski      e-mail: rems@gdansk.sprint.pl           * *        
-----------------------------------------------------------------*****----------



pgsql-sql by date:

Previous
From: "Stéphane FILLON"
Date:
Subject: CREATE FUNCTION
Next
From: José Soares
Date:
Subject: Re: [SQL] CREATE FUNCTION