Last active
July 9, 2020 12:39
-
-
Save prgTW/655722dae829ddb9322f6017b0d1a786 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
SET profiling = 1; -- don't worry, it's per-session setting | |
SELECT 1 | |
FROM `agreement` | |
LEFT JOIN `product1` ON ( | |
`agreement`.`id`=`product1`.`agreement_id` | |
AND `product1`.`status` IN ('active', 'expiring') | |
) | |
LEFT JOIN `product2` ON ( | |
`agreement`.`id`=`product2`.`agreement_id` | |
AND `product2`.`status` IN ('active', 'expiring') | |
) | |
WHERE `agreement`.customer_id = :id | |
GROUP BY agreement.id | |
HAVING count(product1.id) > 0 OR count(product2.id) > 0 | |
LIMIT 1; | |
SHOW PROFILE ALL FOR QUERY 1; -- now, we show our profile in most detailed way | |
-- SET profiling = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment