Received: from database.sarang.net (210-217-214-241.panworldnet.com [210.217.214.241]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f92J9Un44873 for ; Tue, 2 Oct 2001 15:09:30 -0400 (EDT) (envelope-from advance@database.sarang.net) Received: (from advance@localhost) by database.sarang.net (8.11.6/8.11.6) id f92J9RY27574 for pgsql-sql@postgresql.org; Wed, 3 Oct 2001 04:09:27 +0900 Date: Wed, 3 Oct 2001 04:09:27 +0900 From: =?euc-kr?B?SmVvbmcgSmFlaWNrLCDBpMDnwM0=?= To: pgsql-sql@postgresql.org Subject: Re: Question about indexing! Message-ID: <20011003040927.A27380@database.sarang.net> Reply-To: =?euc-kr?B?SmVvbmcgSmFlaWNrLCDBpMDnwM0=?= Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Archive-Number: 200110/30 X-Sequence-Number: 4985 pgsql_bbs table has about 15,000 rows! And almost of them are satify (topic='qna' and deleted<2) condition. This explain result have a large cost. I want to low this query cost. Thanks for your concern :-) >> 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 widt >h=245) > >It appears to be using the topic_deleted index according to this >explain output. >How many rows actually have topic='qna' and deleted<2? -- ==================================================== mailto:advance@advance.sarang.net http://database.sarang.net Dept of Neurosurgery, Dong-eui Medical Center ====================================================