-
-
Couldn't load subscription status.
- Fork 585
Closed
Labels
Description
Hi,
The following query took several seconds to resolve on an m5.2xlarge:
SELECT instances.uid, instances.extra
FROM instances
WHERE (EXISTS (SELECT 1
FROM queries
WHERE instances.uid = queries.instance_uid AND queries.`sql` = '...' AND (EXISTS (SELECT 1
FROM query_tags
WHERE queries.uid = query_tags.query_uid AND query_tags.tag = 'primary')))) AND (EXISTS (SELECT 1
FROM query_tags, queries
WHERE queries.uid = query_tags.query_uid AND query_tags.tag = 'bird_gpt35_kg_cot'))
In particular both the pieces of query_tags filtering made this much slower than filtering based on the sql query alone, loading the relevant instance by uid, loading all the queries by uid, then loading all the tags by uid, and doing the filtering manually in python.