Question about indexing!

From: Jeong Jaeick, 정재익 <advance(at)advance(dot)sarang(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Question about indexing!
Date: 2001-10-02 11:45:30
Message-ID: 20011002204530.A10791@database.sarang.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I made the table like this;

dsn=# \d pgsql_bbs
Table "pgsql_bbs"
Attribute | Type | Modifier
-------------+---------+-------------------------------------------------
id | integer | not null default nextval('pgsql_bbs_seq'::text)
topic | text |
cdate | integer | default (abstime(now()))::int4
subject | text |
content | text |
deleted | integer | default 0
gid | integer | not null
pos | integer | not null
pid | integer | not null
rdepth | integer | not null
Indices: pgsql_bbs_pkey,
pgsql_cdate,
pgsql_deleted,
pgsql_gid,
pgsql_gid_pos,
pgsql_pid,
pgsql_pos,
pgsql_topic,
pgsql_topic_deleted,
pgsql_uid

And I tried next query;

select * from pgsql_bbs where topic = 'qna' and deleted < 2
order by gid desc, pos asc limit 20, 0;

But this query is not using index!

The next is result of explain of this query:

dsn=# explain select * from pgsql_bbs where topic = 'qna' and deleted < 2
dsn-# order by gid desc, pos asc limit 20, 0;
NOTICE: QUERY PLAN:

Limit (cost=15.71..15.71 rows=11 width=245)
-> Sort (cost=15.71..15.71 rows=11 width=245)
-> Index Scan using pgsql_topic_deleted on pgsql_bbs (cost=0.00..15.51 rows=11 width=245)

EXPLAIN

How method is exist enhancing performance of this query?

Thank you for read this question.

--
====================================================
mailto:advance(at)advance(dot)sarang(dot)net
http://database.sarang.net
Dept of Neurosurgery, Dong-eui Medical Center
====================================================

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-10-02 14:56:11 Re: 7.0.3 and 7.1.3 different results?
Previous Message Nils Zonneveld 2001-10-02 10:30:12 Re: Stupid Question