SQL Help - Finding Next Lowest Value of Current Row Value

From: Jeff Adams <Jeff(dot)Adams(at)noaa(dot)gov>
To: pgsql-general(at)postgresql(dot)org
Subject: SQL Help - Finding Next Lowest Value of Current Row Value
Date: 2011-10-01 21:30:47
Message-ID: 000001cc8081$65bb4510$3131cf30$%Adams@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings,

I have a large table (~19 million records). Records contains a field
identifying a vessel and a field containing an time (epoch). Using the
current rows vessel and time values, I need to be able to find the next
lowest time value for the vessel and use it to compute how much time has
elapsed between the records. I have tried a scalar subquery in the SELECT,
which works, but it runs quite slowly. Is there an alternative approach that
might perform better for this type of query. Any information would be
greatly appreciated. Thanks...

Jeff

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2011-10-01 22:50:26 Re: SQL Help - Finding Next Lowest Value of Current Row Value
Previous Message Leif Biberg Kristensen 2011-10-01 21:16:06 Re: How to find freak UTF-8 character?