Created
August 4, 2016 23:01
-
-
Save saltyskip/26166267a49c3726a6d44b206d02dd5a to your computer and use it in GitHub Desktop.
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
EXPLAIN (SELECT * FROM (( | |
SELECT id, status, 'purchase' AS type, | |
user_id, NULL AS to_user_id, amount, | |
bonus_amount, NULL AS fee, payment_id, | |
type AS sub_type, | |
finalized_at, created_at | |
FROM purchase WHERE 1 AND created_at < FROM_UNIXTIME(1)) UNION ( | |
SELECT id, status, 'payment' AS type, | |
user_id, to_user_id, amount, | |
NULL AS bonus_amount, processing_fee AS FEE, | |
NULL AS payment_id, | |
type AS sub_type, finalized_at, created_at | |
FROM payment WHERE 1 AND created_at < FROM_UNIXTIME(1)) UNION ( | |
SELECT id, status, 'refund' AS type, | |
user_id, NULL AS to_user_id, amount, | |
NULL AS bonus_amount, NULL AS fee, | |
payment_id, | |
NULL AS sub_type, finalized_at, created_at | |
FROM refund WHERE 1 AND created_at < FROM_UNIXTIME(1))) previous ORDER BY created_at DESC LIMIT 250 )UNION( SELECT * FROM (( | |
SELECT id, status, 'purchase' AS type, | |
user_id, NULL AS to_user_id, amount, | |
bonus_amount, NULL AS fee, payment_id, | |
type AS sub_type, | |
finalized_at, created_at | |
FROM purchase WHERE 1 AND created_at > FROM_UNIXTIME(1)) UNION ( | |
SELECT id, status, 'payment' AS type, | |
user_id, to_user_id, amount, | |
NULL AS bonus_amount, processing_fee AS FEE, | |
NULL AS payment_id, | |
type AS sub_type, finalized_at, created_at | |
FROM payment WHERE 1 AND created_at > FROM_UNIXTIME(1)) UNION ( | |
SELECT id, status, 'refund' AS type, | |
user_id, NULL AS to_user_id, amount, | |
NULL AS bonus_amount, NULL AS fee, | |
payment_id, | |
NULL AS sub_type, finalized_at, created_at | |
FROM refund WHERE 1 AND created_at > FROM_UNIXTIME(1))) next ORDER BY created_at ASC LIMIT 250 )ORDER BY created_at DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment