Dropping tag doesn't fix performance. OOPS without tag; OOPS-260c8d819920d52445bc1e437bd80ea8 SELECT BugTask.status, BugTask.assignee, BugTask.bug, BugTask.bugwatch, BugTask.date_assigned, BugTask.date_closed, BugTask.date_confirmed, BugTask.date_fix_committed, BugTask.date_fix_released, BugTask.date_incomplete, BugTask.date_inprogress, BugTask.date_left_closed, BugTask.date_left_new, BugTask.date_triaged, BugTask.datecreated, BugTask.distribution, BugTask.distroseries, BugTask.heat, BugTask.id, BugTask.importance, BugTask.milestone, BugTask.owner, BugTask.product, BugTask.productseries, BugTask.sourcepackagename, BugTask.targetnamecache, Bug.date_last_message, Bug.date_last_updated, Bug.date_made_private, Bug.datecreated, Bug.description, Bug.duplicateof, Bug.heat, Bug.heat_last_updated, Bug.id, Bug.latest_patch_uploaded, Bug.message_count, Bug.name, Bug.number_of_duplicates, Bug.owner, Bug.private, Bug.security_related, Bug.title, Bug.users_affected_count, Bug.users_unaffected_count, Bug.who_made_private FROM BugTask JOIN Bug ON BugTask.bug = Bug.id WHERE Bug.id = BugTask.bug AND BugTask.importance IN (5) AND BugTask.distribution = 1 AND (BugTask.status IN (10)) AND Bug.duplicateof is NULL AND BugTask.id IN ( SELECT BugTask.id FROM BugTask, Product WHERE BugTask.product = Product.id AND Product.bug_supervisor = 343381 UNION ALL SELECT BugTask.id FROM BugTask, StructuralSubscription WHERE BugTask.distribution = StructuralSubscription.distribution AND BugTask.sourcepackagename = StructuralSubscription.sourcepackagename AND StructuralSubscription.subscriber = 343381 UNION ALL SELECT BugTask.id FROM BugTask, Distribution WHERE BugTask.distribution = Distribution.id AND Distribution.bug_supervisor = 343381 ) AND (Bug.private = FALSE OR EXISTS ( WITH teams AS ( SELECT team from TeamParticipation WHERE person = 2 ) SELECT BugSubscription.bug FROM BugSubscription WHERE BugSubscription.person IN (SELECT team FROM teams) AND BugSubscription.bug = Bug.id UNION SELECT BugTask.bug FROM BugTask WHERE BugTask.assignee IN (SELECT team FROM teams) AND BugTask.bug = Bug.id UNION SELECT BugTask.bug FROM BugTask, Product WHERE Product.owner IN (SELECT team FROM teams) AND BugTask.product = Product.id AND BugTask.bug = Bug.id AND Bug.security_related IS False UNION SELECT BugTask.bug FROM BugTask, ProductSeries WHERE ProductSeries.owner IN (SELECT team FROM teams) AND BugTask.productseries = ProductSeries.id AND BugTask.bug = Bug.id AND Bug.security_related IS False UNION SELECT BugTask.bug FROM BugTask, Distribution WHERE Distribution.owner IN (SELECT team FROM teams) AND BugTask.distribution = Distribution.id AND BugTask.bug = Bug.id AND Bug.security_related IS False UNION SELECT BugTask.bug FROM BugTask, DistroSeries, Distribution WHERE Distribution.owner IN (SELECT team FROM teams) AND DistroSeries.distribution = Distribution.id AND BugTask.distroseries = DistroSeries.id AND BugTask.bug = Bug.id AND Bug.security_related IS False )) ORDER BY BugTask.datecreated LIMIT 76 OFFSET 0 explain: Limit (cost=16707.17..149356.52 rows=76 width=921) (actual time=29718.551..178256.887 rows=23 loops=1) -> Nested Loop Semi Join (cost=16707.17..48683307.80 rows=27883 width=921) (actual time=29718.549..178256.853 rows=23 loops=1) Join Filter: (public.bugtask.id = public.bugtask.id) -> Nested Loop (cost=0.00..18311341.12 rows=55765 width=921) (actual time=524.687..7968.051 rows=44273 loops=1) -> Index Scan using bugtask__datecreated__idx on bugtask (cost=0.00..99933.00 rows=73926 width=161) (actual time=297.001..4474.815 rows=152198 loops=1) Filter: ((importance = 5) AND (distribution = 1) AND (status = 10)) -> Index Scan using bug_pkey on bug (cost=0.00..246.33 rows=1 width=760) (actual time=0.021..0.022 rows=0 loops=152198) Index Cond: (bug.id = public.bugtask.bug) Filter: ((bug.duplicateof IS NULL) AND ((NOT bug.private) OR (SubPlan 2))) SubPlan 2 -> HashAggregate (cost=244.40..244.46 rows=6 width=4) (actual time=0.336..0.336 rows=1 loops=3131) CTE teams -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..178.02 rows=132 width=4) (actual time=0.038..0.610 rows=142 loops=1) Index Cond: (person = 2) -> Append (cost=4.29..66.36 rows=6 width=4) (actual time=0.148..0.326 rows=1 loops=3131) -> Hash Semi Join (cost=4.29..8.68 rows=1 width=4) (actual time=0.092..0.101 rows=1 loops=3131) Hash Cond: (bugsubscription.person = teams.team) -> Index Scan using bugsubscription_bug_idx on bugsubscription (cost=0.00..4.39 rows=3 width=8) (actual time=0.072..0.092 rows=4 loops=3131) Index Cond: (bug = $1) -> Hash (cost=2.64..2.64 rows=132 width=4) (actual time=0.723..0.723 rows=142 loops=1) -> CTE Scan on teams (cost=0.00..2.64 rows=132 width=4) (actual time=0.042..0.681 rows=142 loops=1) -> Nested Loop Semi Join (cost=0.00..8.23 rows=1 width=4) (actual time=0.085..0.085 rows=0 loops=3131) Join Filter: (public.bugtask.assignee = teams.team) -> Index Scan using bugtask__bug__idx on bugtask (cost=0.00..3.94 rows=1 width=8) (actual time=0.021..0.022 rows=1 loops=3131) Index Cond: (bug = $1) -> CTE Scan on teams (cost=0.00..2.64 rows=132 width=4) (actual time=0.001..0.030 rows=142 loops=3260) -> Result (cost=0.00..12.11 rows=1 width=4) (actual time=0.018..0.018 rows=0 loops=3131) One-Time Filter: ($2 IS FALSE) -> Nested Loop Semi Join (cost=0.00..12.11 rows=1 width=4) (actual time=0.016..0.016 rows=0 loops=3106) Join Filter: (public.product.owner = teams.team) -> Nested Loop (cost=0.00..7.82 rows=1 width=8) (actual time=0.014..0.014 rows=0 loops=3106) -> Index Scan using bugtask__bug__idx on bugtask (cost=0.00..3.94 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=3106) Index Cond: (bug = $1) -> Index Scan using product_pkey on product (cost=0.00..3.87 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=3230) Index Cond: (public.product.id = public.bugtask.product) -> CTE Scan on teams (cost=0.00..2.64 rows=132 width=4) (actual time=0.001..0.017 rows=110 loops=30) -> Result (cost=0.00..12.11 rows=1 width=4) (actual time=0.015..0.015 rows=0 loops=3131) One-Time Filter: ($2 IS FALSE) -> Nested Loop Semi Join (cost=0.00..12.11 rows=1 width=4) (actual time=0.013..0.013 rows=0 loops=3106) Join Filter: (productseries.owner = teams.team) -> Nested Loop (cost=0.00..7.82 rows=1 width=8) (actual time=0.011..0.011 rows=0 loops=3106) -> Index Scan using bugtask__bug__idx on bugtask (cost=0.00..3.94 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=3106) Index Cond: (bug = $1) -> Index Scan using productseries_pkey on productseries (cost=0.00..3.87 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=3230) Index Cond: (productseries.id = public.bugtask.productseries) -> CTE Scan on teams (cost=0.00..2.64 rows=132 width=4) (never executed) -> Result (cost=0.00..12.11 rows=1 width=4) (actual time=0.081..0.081 rows=0 loops=3131) One-Time Filter: ($2 IS FALSE) -> Nested Loop Semi Join (cost=0.00..12.11 rows=1 width=4) (actual time=0.079..0.079 rows=0 loops=3106) Join Filter: (public.distribution.owner = teams.team) -> Nested Loop (cost=0.00..7.82 rows=1 width=8) (actual time=0.022..0.024 rows=1 loops=3106) -> Index Scan using bugtask__bug__idx on bugtask (cost=0.00..3.94 rows=1 width=8) (actual time=0.005..0.006 rows=1 loops=3106) Index Cond: (bug = $1) -> Index Scan using distribution_pkey on distribution (cost=0.00..3.87 rows=1 width=8) (actual time=0.011..0.012 rows=1 loops=3230) Index Cond: (public.distribution.id = public.bugtask.distribution) -> CTE Scan on teams (cost=0.00..2.64 rows=132 width=4) (actual time=0.000..0.024 rows=142 loops=3143) -> Result (cost=0.00..13.06 rows=1 width=4) (actual time=0.018..0.018 rows=0 loops=3131) One-Time Filter: ($2 IS FALSE) -> Nested Loop Semi Join (cost=0.00..13.06 rows=1 width=4) (actual time=0.017..0.017 rows=0 loops=3106) Join Filter: (public.distribution.owner = teams.team) -> Nested Loop (cost=0.00..8.77 rows=1 width=8) (actual time=0.014..0.014 rows=0 loops=3106) -> Nested Loop (cost=0.00..7.82 rows=1 width=8) (actual time=0.013..0.013 rows=0 loops=3106) -> Index Scan using bugtask__bug__idx on bugtask (cost=0.00..3.94 rows=1 width=8) (actual time=0.007..0.008 rows=1 loops=3106) Index Cond: (bug = $1) -> Index Scan using distrorelease_pkey on distroseries (cost=0.00..3.87 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=3230) Index Cond: (distroseries.id = public.bugtask.distroseries) -> Index Scan using distribution_pkey on distribution (cost=0.00..0.94 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=57) Index Cond: (public.distribution.id = distroseries.distribution) -> CTE Scan on teams (cost=0.00..2.64 rows=132 width=4) (actual time=0.000..0.019 rows=142 loops=57) -> Materialize (cost=16707.17..16949.10 rows=24193 width=4) (actual time=0.000..1.586 rows=12163 loops=44273) -> Append (cost=2.48..16682.98 rows=24193 width=4) (actual time=0.163..47.980 rows=12165 loops=1) -> Nested Loop (cost=2.48..99.60 rows=11 width=4) (actual time=0.022..0.022 rows=0 loops=1) -> Index Scan using product__bug_supervisor__idx on product (cost=0.00..3.87 rows=1 width=4) (actual time=0.022..0.022 rows=0 loops=1) Index Cond: (bug_supervisor = 343381) -> Bitmap Heap Scan on bugtask (cost=2.48..95.09 rows=52 width=8) (never executed) Recheck Cond: (public.bugtask.product = public.product.id) -> Bitmap Index Scan on bugtask__product__bug__key (cost=0.00..2.47 rows=52 width=0) (never executed) Index Cond: (public.bugtask.product = public.product.id) -> Nested Loop (cost=3.50..922.99 rows=6651 width=4) (actual time=0.139..45.867 rows=12165 loops=1) -> Bitmap Heap Scan on structuralsubscription (cost=3.50..185.88 rows=187 width=8) (actual time=0.091..0.689 rows=187 loops=1) Recheck Cond: (subscriber = 343381) -> Bitmap Index Scan on structuralsubscription__subscriber__idx (cost=0.00..3.45 rows=187 width=0) (actual time=0.068..0.068 rows=188 loops=1) Index Cond: (subscriber = 343381) -> Index Scan using bugtask__distribution_sourcepackage__heat__idx on bugtask (cost=0.00..3.93 rows=1 width=12) (actual time=0.016..0.227 rows=65 loops=187) Index Cond: ((public.bugtask.distribution = structuralsubscription.distribution) AND (public.bugtask.sourcepackagename = structuralsubscription.sourcepackagename)) -> Nested Loop (cost=0.00..15418.46 rows=17531 width=4) (actual time=0.014..0.014 rows=0 loops=1) -> Index Scan using distribution__bug_supervisor__idx on distribution (cost=0.00..3.87 rows=1 width=4) (actual time=0.013..0.013 rows=0 loops=1) Index Cond: (bug_supervisor = 343381) -> Index Scan using bugtask__distribution_sourcepackage__heat__idx on bugtask (cost=0.00..15168.06 rows=19723 width=8) (never executed) Index Cond: (public.bugtask.distribution = public.distribution.id) Total runtime: 178258.868 ms