Re: Problems with order by, limit, and indices

From: Denis Perchine <dyp(at)perchine(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with order by, limit, and indices
Date: 2001-01-07 11:02:15
Message-ID: 01010717021500.11873@dyp.perchine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

another interesting thing...
This is current 7.1.

slygreetings=> explain select * from users where variant_id=5 AND active='f'
order by rcptdate,variant_id,active limit 60;
NOTICE: QUERY PLAN:

Limit (cost=13005.10..13005.10 rows=60 width=145)
-> Sort (cost=13005.10..13005.10 rows=3445 width=145)
-> Index Scan using users_rcptdate_vid_key on users
(cost=0.00..12658.35 rows=3445 width=145)

EXPLAIN
slygreetings=> set enable_sort to off;
SET VARIABLE
slygreetings=> explain select * from users where variant_id=5 AND active='f'
order by rcptdate,variant_id,active limit 60;
NOTICE: QUERY PLAN:

Limit (cost=100013005.10..100013005.10 rows=60 width=145)
-> Sort (cost=100013005.10..100013005.10 rows=3445 width=145)
-> Index Scan using users_rcptdate_vid_key on users
(cost=0.00..12658.35 rows=3445 width=145)

EXPLAIN

Cost is something really wierd.... Why?

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp(at)perchine(dot)com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Boon Yeo 2001-01-07 11:02:19 c++ wrappers
Previous Message Mihail Marinov 2001-01-07 09:09:03 Re[2]: DROP SEQUENCE ?