-
-
Save jeff/50e287ddb80b416c15cac6775617884c 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
-- little slower | |
WITH linked_outputs AS ( | |
SELECT templates.id AS id FROM ( | |
SELECT DISTINCT(template_output) AS id | |
FROM action_trigger.event WHERE template_output IS NOT NULL | |
UNION | |
SELECT DISTINCT(error_output) AS id | |
FROM action_trigger.event WHERE error_output IS NOT NULL | |
UNION | |
SELECT DISTINCT(async_output) AS id | |
FROM action_trigger.event WHERE async_output IS NOT NULL | |
) templates | |
) | |
SELECT id FROM action_trigger.event_output WHERE id NOT IN (SELECT id FROM linked_outputs); | |
-- little faster | |
SELECT ateo.id | |
FROM action_trigger.event_output AS ateo | |
WHERE NOT EXISTS (SELECT 1 FROM action_trigger.event WHERE template_output = ateo.id) | |
AND NOT EXISTS (SELECT 1 FROM action_trigger.event WHERE error_output = ateo.id) | |
AND NOT EXISTS (SELECT 1 FROM action_trigger.event WHERE async_output = ateo.id); | |
-- very slow! | |
SELECT ateo.id | |
FROM action_trigger.event_output AS ateo | |
LEFT JOIN action_trigger.event AS ate ON ( | |
ateo.id = ate.template_output | |
OR ateo.id = ate.error_output | |
OR ateo.id = ate.async_output | |
) | |
WHERE ate IS NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment