| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Nested Sets vs. Nested Intervals
The rating is between 0 and 100.
Is this more efficient to select the top ten listings:
SELECT listings.*
FROM listings
WHERE listings.lft_index
BETWEEN node.a11/node.a21 - 0.00000001 AND
(node.a11-node.a12)/(node.a21-node.a22) + 0.00000001
AND listings.rating >= 50
or this:
DECLARE cnt INT;
DECLARE number INT;
SET number = 75;
REPEAT SET number = number - 3;
SELECT COUNT(*) INTO cnt
FROM listings
WHERE listings.lft_index
BETWEEN node.a11/node.a21 - 0.00000001 AND
(node.a11-node.a12)/(node.a21-node.a22) + 0.00000001
AND listings.rating >= number
UNTIL cnt >= 10
END REPEAT;
SELECT listings.*
FROM listings
WHERE listings.lft_index
BETWEEN node.a11/node.a21 - 0.00000001 AND
(node.a11-node.a12)/(node.a21-node.a22) + 0.00000001
AND listings.rating >= number
![]() |
![]() |