Received: from candle.pha.pa.us (maillist@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.8.8/8.8.8) with ESMTP id BAA23947 for ; Thu, 15 Oct 1998 01:52:26 -0400 (EDT) (envelope-from maillist@candle.pha.pa.us) Received: (from maillist@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id BAA07576; Thu, 15 Oct 1998 01:52:06 -0400 (EDT) From: Bruce Momjian Message-Id: <199810150552.BAA07576@candle.pha.pa.us> Subject: Re: [HACKERS] What about LIMIT in SELECT ? In-Reply-To: from Jan Wieck at "Oct 14, 1998 11: 5: 7 pm" To: jwieck@debis.com Date: Thu, 15 Oct 1998 01:52:06 -0400 (EDT) Cc: lockhart@alumni.caltech.edu, jwieck@debis.com, eric@linux-hw.com, jeff@remapcorp.com, hackers@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL47 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > > I have had more time to think about this. Basically, for pre-sorted > > data, our psort code is very fast, because it does not need to sort > > anything. It just moves the rows in and out of the sort memory. Yes, > > it could be removed in some cases, and probably should be, but it is not > > going to produce great speedups. > > And I got the time to hack around about this. > > I hacked in a little check into the planner, that compares > the sortClause against the key field list of an index scan > and just suppresses the sort node if it exactly matchs and > all sort operators are "<". > > I tested with a 10k row table where key is a text field. The > base query is a > > SELECT ... WHERE key > 'val' ORDER BY key; > > The used 'val' is always a key that is close to the first of > all keys in the table ('' on the first query and the last > selected value on subsequent ones). This is good stuff. I want to think about it for a day. Sounds very promising. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026