Skip to content

Instantly share code, notes, and snippets.

@pradeepwebonise
pradeepwebonise / gist:b43eae784ba6b30cfbed
Created July 29, 2015 11:44
Leaderboard Data query with indexing
/* 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
@pradeepwebonise
pradeepwebonise / gist:885c57764a0314ebe4e0
Created July 29, 2015 11:42
Leaderboard Data query with indexing
/* 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
@pradeepwebonise
pradeepwebonise / gist:c514c4c1180824c9b1f5
Created July 29, 2015 11:42
Leaderboard Data query with indexing
/* 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
@pradeepwebonise
pradeepwebonise / gist:02a4c4712f33fb1f27dd
Last active August 29, 2015 14:26
All tournaments with tournament ids to which user had made entries [ without indexing ]
-- getting all tournaments with tournament ids to which user had made entries-------------
EXPLAIN PLAN FOR
SELECT * FROM (
SELECT rownum as rn, a.* FROM (
SELECT * FROM Tournament t WHERE t.published = 1 AND t.closed = 0 AND t.cancelled = 0 AND t.submission_deadline >= '20-05-15 06:45:00.000000000 AM' AND ( t.is_private = 0 OR (t.tournament_id IN (132, 131) OR t.allowed_user_emails LIKE '%bkhanna@drf.com') ) ORDER BY submission_deadline ASC
) a
) WHERE rownum <= 10 AND rn > (1 - 1) * 10
============ Output ========================
@pradeepwebonise
pradeepwebonise / gist:91b4a5697ab49e1dbddf
Created July 29, 2015 11:31
All tournaments for non logged in users
/* All tournaments for non logged in users */
EXPLAIN PLAN FOR
SELECT * FROM (
SELECT rownum as rn, a.* FROM (
SELECT * FROM Tournament t WHERE t.published = 1 AND t.closed = 0 AND t.cancelled = 0 AND t.submission_deadline >= '07/21/2015 10:30 AM' AND t.is_private = 0 ORDER BY submission_deadline ASC
) a
) WHERE rownum <= 10 AND rn > (1 - 1) * 10
@pradeepwebonise
pradeepwebonise / gist:3cc6c661cb74ba549822
Created July 29, 2015 11:28
Leaderboard Data query without indexing
/* 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