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 03:03:56 GMT
Message-ID: <wMiRh.120081$115.78151@newsfe10.phx>


"John" <acide.ascorbique_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 Received on Thu Apr 05 2007 - 22:03:56 CDT

Original text of this message

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