How improve such query?

From: Remigiusz Sokolowski <rems(at)gdansk(dot)sprint(dot)pl>
To: pgsql-sql(at)postgresql(dot)org
Subject: How improve such query?
Date: 1999-09-16 11:24:20
Message-ID: Pine.GS4.4.02A.9909161310290.23956-100000@netra.gdansk.sprint.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 advance
Rem

--

-------------------------------------------------------------------*------------
Remigiusz Sokolowski e-mail: rems(at)gdansk(dot)sprint(dot)pl * *
-----------------------------------------------------------------*****----------

Browse pgsql-sql by date

  From Date Subject
Next Message José Soares 1999-09-16 12:49:49 Re: [SQL] CREATE FUNCTION
Previous Message Craig Orsinger 1999-09-15 18:21:55 RE: RE[2]: [INTERFACES] ecpg and getting just assigned serial nu