Created
July 29, 2015 11:42
-
-
Save pradeepwebonise/885c57764a0314ebe4e0 to your computer and use it in GitHub Desktop.
Leaderboard Data query with indexing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Leaderboard Data query */ | |
EXPLAIN PLAN FOR | |
SELECT userId, firstName, lastName, userName, email, entryId, totalPayouts FROM ( | |
SELECT rownum as rn, a.* FROM ( | |
SELECT u.user_id userId, u.first_name firstName, u.last_name lastName, | |
u.user_name userName, tep.entry_id entryId, | |
NVL( SUM(p.payouts), 0 ) totalPayouts ,u.email email | |
FROM USERS u, TOURNAMENT_USERS_ENTRY tue, TOURNAMENT_ENTRY_PICK tep | |
LEFT JOIN PICK_PAYOUT p ON tep.pick_id = p.pick_id | |
WHERE u.user_id = tue.user_id AND | |
tue.tournament_id = 110 AND | |
tep.entry_id = tue.entry_id | |
GROUP BY u.user_id, u.first_name, u.last_name, u.user_name, tep.entry_id , u.email | |
ORDER BY totalPayouts DESC, firstName, lastName | |
) a | |
) WHERE rownum <= 10 AND rn > (1 - 1) * 10; | |
==================================== OUTPUT ============================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment