Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL: Working with huge tables of chronological data

Re: SQL: Working with huge tables of chronological data

From: Ana C. Dent <anacedent_at_hotmail.com>
Date: Fri, 06 Apr 2007 14:49:27 GMT
Message-ID: <X5tRh.123044$Ko5.85648@newsfe08.phx>


"EdStevens" <quetico_man_at_yahoo.com> wrote in news:1175870668.939557.173360_at_y66g2000hsf.googlegroups.com:

> On Apr 5, 10:03 pm, "Ana C. Dent" <anaced..._at_hotmail.com> wrote:

>> "John" <acide.ascorbi..._at_gmail.com> wrote in
>> news:1175802637.291526.37550 @p77g2000hsh.googlegroups.com:
>>
>>
>>
>> >> Is this the real problem or a simplification?
>> > It's a simplification but not that much. The real problem involves
>> > user_ids but this part can be skipped here.
>>
>> >> Is this something that will be run once or repeatedly?
>> > Only once.
>>
>> >> Is it possible for the same time to be in A and B?
>> > No, A and B are completely different data.
>>
>> >> Is it possible to have a B before an A beginning the sequence?
>> >> Is it possible for there to be multiple Bs between As?
>> > Yes everything is possible, A events and B events happen
>> > independently.
>>
>> > Thanks for being interested in my problem!
>>
>> > John
>>
>> I would NOT use SQL to solve this problem.
>> I'd use Perl or PL/SQL.
>> Treat Table_A & Table_B as ordered lists (based upon field of choice;
>> timestamp, ID , whatever).
>> You only needs to pass thru each list a single time.
>> Open two read loops; one on A & one on B.
>> Read 1 record from each list.
>> 1) If A < B, then read record from A.
>> 2) If A < B, then you found 1st hit & read record from A
>> 3) If B < A, then read record from B
>> 4) If B < A, the you have a hit & read record from B
>> etc. loop until no more records
> 
> Classic sort/merge logic.  Something every cobol programmer learned
> the first week on the job.  Something we often forget with all of our
> point/click/object programming.  Sometimes the old, simple solutions
> are still the best.
> 
> 

I did not claim it to be original, just effective. Yes, I did learn this techique when doing Cobol programming. Received on Fri Apr 06 2007 - 09:49:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US