X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BBB252939 for ; Tue, 21 Jun 2005 11:43:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15414-09 for ; Tue, 21 Jun 2005 14:42:56 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA10B52806 for ; Tue, 21 Jun 2005 11:42:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j5LEgrrp003416; Tue, 21 Jun 2005 10:42:53 -0400 (EDT) To: Yves Vindevogel Cc: pgsql-performance@postgresql.org Subject: Re: Limit clause not using index In-reply-to: References: Comments: In-reply-to Yves Vindevogel message dated "Tue, 21 Jun 2005 16:33:55 +0200" Date: Tue, 21 Jun 2005 10:42:53 -0400 Message-ID: <3415.1119364973@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/379 X-Sequence-Number: 13016 Yves Vindevogel writes: > Can anyone explain me this ? > rvponp=# explain select * from tblprintjobs order by loginuser, > desceventdate, desceventtime offset 25 limit 25 ; > QUERY PLAN > ------------------------------------------------------------------------ > ----------- > Limit (cost=349860.62..349860.68 rows=25 width=206) > -> Sort (cost=349860.56..351416.15 rows=622236 width=206) > Sort Key: loginuser, desceventdate, desceventtime > -> Seq Scan on tblprintjobs (cost=0.00..25589.36 rows=622236 width=206) > (4 rows) Do you have an index matching that sort key? I'd certainly expect the above to use it if it were there. For the full table case it's not so clear --- an indexscan isn't always better. regards, tom lane