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

Home -> Community -> Usenet -> comp.databases.theory -> Re: Nested Sets vs. Nested Intervals

Re: Nested Sets vs. Nested Intervals

From: asdf <xyz91234_at_yahoo.com>
Date: 4 Dec 2005 10:12:42 -0800
Message-ID: <1133719962.641882.81630@g49g2000cwa.googlegroups.com>


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
ORDER BY listings.rating DESC LIMIT 0, 10

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
ORDER BY listings.rating DESC LIMIT 0, 10 Received on Sun Dec 04 2005 - 12:12:42 CST

Original text of this message

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