Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id VAA08373 for postgres-redist; Sat, 17 Sep 1994 21:20:31 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199409180420.VAA08373@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from EIGER.EDRC.CMU.EDU (EIGER.EDRC.CMU.EDU [128.2.214.41]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id VAA08363 for <postgres@postgres.berkeley.edu>; Sat, 17 Sep 1994 21:20:30 -0700
Received: from Messages.8.5.N.CUILIB.3.45.SNAP.NOT.LINKED.EIGER.EDRC.CMU.EDU.pmax.mach
          via MS.5.6.EIGER.EDRC.CMU.EDU.pmax_mach;
          Sun, 18 Sep 1994 00:20:15 -0400 (EDT)
Message-ID: <AiSvzza00hMdQ87lUv@cs.cmu.edu>
Date: Sun, 18 Sep 1994 00:20:15 -0400 (EDT)
From: Robert.Patrick@cs.cmu.edu
To: postgres@postgres.Berkeley.EDU
Subject: Re: Last 'n' records?
In-Reply-To: <m0qlkES-0009C9C@dl6rai.muc.de>
References: <m0qlkES-0009C9C@dl6rai.muc.de>
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Sat, 17 Sep 94 21:20:31 -0700
Resent-XMts: smtp

Excerpts from internet.postgres: 16-Sep-94 Last 'n' records? Bernhard
Buettner@DL6RAI (1441*)

> A problem arises with the fact that very often a user wants to  retrieve
> "the last 'n'" records of the database. Reading through the manual, I
> could not find an operator to do this. At this time, the query is
> realised as follows:

>      retrieve portal P unique (data.all) sort by date using >
>      fetch 5 in P

> This will take the whole relation, sort it by date and then retrieve the
> last 5 (0.01%). This cannot be the solution, but we can't find any
> better. Any hints, ideas?

The only solution (partial solution, anyway) I can see is to specify a
range on the dates so that only records with recent dates will be
retrieved.  If you really have 10,000 records/month, try limiting your
query to those records which match today's date (or yesterday's and
today's).




==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
