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

Home -> Community -> Usenet -> c.d.o.misc -> Ora 9.2 SQL: What's the fastest way to do this set operation...

Ora 9.2 SQL: What's the fastest way to do this set operation...

From: dean <deanbrown3d_at_yahoo.com>
Date: 29 Apr 2006 22:04:57 -0700
Message-ID: <1146373497.014686.264300@y43g2000cwc.googlegroups.com>


Imagine I have a database of 10,000 trains and their ordered list of (around 2 million) scheduled locations, keyed on those trains and an order number. I want to go from A to B and there are no direct trains. I need to find all the pairs of trains, one going through A and the other through B, that share AT LEAST ONE OTHER location in common, call it C.

The only way I can think of doing it is to find the set of trains T_A that go through A, and the set of trains T_B that go through B, and see if there is any intersection in their route locations.

As far as I can tell, doing the INTERSECT means actually calculating the entire intersection, even though I only need to know that at least one location is common to both trains.

Is there a fast function in oracle (9.2) that will do something like this - something along the lines of OVERLAPS.

If I do the join on LOCATION, or a count of locations in T_A that are in T_B, I get the correct answer but it is taking 10 seconds+, and I'd like to reduce that.

Thanks for any help.

Dean Received on Sun Apr 30 2006 - 00:04:57 CDT

Original text of this message

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