dbTalk Databases Forums  

[BUGS] BUG #1122: limit 1 doing a sequential scan

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #1122: limit 1 doing a sequential scan in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
PostgreSQL Bugs List
 
Posts: n/a

Default [BUGS] BUG #1122: limit 1 doing a sequential scan - 04-02-2004 , 03:31 PM







The following bug has been logged online:

Bug reference: 1122
Logged by: P Buder

Email address: pb2 (AT) aracnet (DOT) com

PostgreSQL version: 7.3.5

Operating system: Debian Linux

Description: limit 1 doing a sequential scan

Details:

I am actually running 7.3.6 but that isn't available on the drop down menu
to report a bug so there is another bug

When I do a select * from table limit 1
Postgresql does a sequential scan on the whole table. It should just pick
one row and be done with it. The table has been analyzed but that shouldn't
matter. This particular table has 4.3 million rows. Here is the explain
select.


book=# explain select * from imdata limit 1;
QUERY PLAN
----------------------------------------------------------------------
Limit (cost=0.00..55.85 rows=1 width=152)
-> Seq Scan on imdata (cost=0.00..269569.27 rows=4827 width=152)
(2 rows)




---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1122: limit 1 doing a sequential scan - 04-02-2004 , 03:41 PM






"PostgreSQL Bugs List" <pgsql-bugs (AT) postgresql (DOT) org> writes:
Quote:
When I do a select * from table limit 1
Postgresql does a sequential scan on the whole table.
AFAICS you simply are misreading the EXPLAIN output.

(It also sounds like you haven't vacuumed or analyzed that table in a
mighty long time... if you're having performance problems that is
probably the reason...)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.