agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
Last 'n' records?
2+ messages / 2 participants
[nested] [flat]

* Last 'n' records?
@ 1994-09-16 20:50  Bernhard Buettner <root@DL6RAI.MUC.DE>
  0 siblings, 1 reply; 2+ messages in thread

From: Bernhard Buettner @ 1994-09-16 20:50 UTC (permalink / raw)
  To: legacy

Hello Postgres experts,

I am currently developing amateur radio software utilizig Postgres 
with a friend. The application is going to be used as an on-line 
database run under packet radio. The database contains data records 
which are being entered by many different users and the growth is about 
10,000 records/month.

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?

Greetings, 

Ben
-- 
[] Bernhard Buettner (Ben)
[]      Mail: Am Brunnen 18, 85551 Kirchheim, Germany
[]  Internet: root@dl6rai.muc.de
[]    Packet: DL6RAI @ DB0AAB.#BAY.DEU.EU

==============================================================================
   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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Last 'n' records?
@ 1994-09-18 04:20  Robert.Patrick@cs.cmu.edu
  parent: Bernhard Buettner <root@DL6RAI.MUC.DE>
  0 siblings, 0 replies; 2+ messages in thread

From: Robert.Patrick@cs.cmu.edu @ 1994-09-18 04:20 UTC (permalink / raw)
  To: legacy

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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1994-09-18 04:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1994-09-16 20:50 Last 'n' records? Bernhard Buettner <root@DL6RAI.MUC.DE>
1994-09-18 04:20 ` Robert.Patrick@cs.cmu.edu

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox