sql - Extremely slow query using CONNECT BY Oracle 10 -


i have table challenge containing 12000 rows. every point connects 4 points around it, example 100 connects 99 101 11 , 189. tried small scale table , worked fine increased size of table query became exponentially slower , won't finish. here's query

select level, origin, destination challenge  destination = 2500 start origin = 1 connect nocycle  prior destination = origin; 

any advice on how optimize query appreciated.

so you're finding every path node 1 node 2500 in degree-4 graph (rectangular lattice?) of thousands of nodes. expect there'll quite lot of them. did challenge ask count them? because think point have figure out how many there doing math, not brute force computation.

for example, if it's 50x50 rectangular grid node 1 , node 2500 in opposite corners, minimum path length 100 steps. path of 100 steps have 50 of them horizontal , 50 of them vertical, , can come in order. figure out how many ways can arrange string of 50 h's , 50 v's , might find it's number mighty oracle have bit of problem with. (generating rows, is. doing calculation requires large integer arithmetic, oracle can quite once tell formula.)

and query worse that. doesn't ask minimum-length paths. return paths of length 102 take step away destination somewhere along way. , paths of length 104 take 2 backward steps. , paths of length 2498 visit of nodes! counting paths more complicated counting short paths because have exclude ones cross themselves.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -