QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=3294847.25..3294847.50 rows=100 width=630) (actual time=87000.978..87009.652 rows=100 loops=1) -> Sort (cost=3294847.25..3295773.17 rows=370371 width=630) (actual time=87000.956..87009.183 rows=100 loops=1) Sort Key: CASE WHEN (((((((head.lrc + neck.lrc) + chest.lrc) + arms.lrc) + hands.lrc) + legs.lrc) + spell.lrc) > 60) THEN 60 ELSE ((((((head.lrc + neck.lrc) + chest.lrc) + arms.lrc) + hands.lrc) + legs.lrc) + spell.lrc) END, ((((CASE WHEN (((((((head.phys + neck.phys) + chest.phys) + arms.phys) + hands.phys) + legs.phys) + spell.phys) > 70) THEN 70 ELSE ((((((head.phys + neck.phys) + chest.phys) + arms.phys) + hands.phys) + legs.phys) + spell.phys) END + CASE WHEN (((((((head.fire + neck.fire) + chest.fire) + arms.fire) + hands.fire) + legs.fire) + spell.fire) > 70) THEN 70 ELSE ((((((head.fire + neck.fire) + chest.fire) + arms.fire) + hands.fire) + legs.fire) + spell.fire) END) + CASE WHEN (((((((head.cold + neck.cold) + chest.cold) + arms.cold) + hands.cold) + legs.cold) + spell.cold) > 70) THEN 70 ELSE ((((((head.cold + neck.cold) + chest.cold) + arms.cold) + hands.cold) + legs.cold) + spell.cold) END) + CASE WHEN (((((((head.poison + neck.poison) + chest.poison) + arms.poison) + hands.poison) + legs.poison) + spell.poison) > 70) THEN 70 ELSE ((((((head.poison + neck.poison) + chest.poison) + arms.poison) + hands.poison) + legs.poison) + spell.poison) END) + CASE WHEN (((((((head.energy + neck.energy) + chest.energy) + arms.energy) + hands.energy) + legs.energy) + spell.energy) > 70) THEN 70 ELSE ((((((head.energy + neck.energy) + chest.energy) + arms.energy) + hands.energy) + legs.energy) + spell.energy) END), CASE WHEN (((((((head.lmc + neck.lmc) + chest.lmc) + arms.lmc) + hands.lmc) + legs.lmc) + spell.lmc) > 15) THEN 15 ELSE ((((((head.lmc + neck.lmc) + chest.lmc) + arms.lmc) + hands.lmc) + legs.lmc) + spell.lmc) END -> Nested Loop (cost=186.79..2821705.50 rows=370371 width=630) (actual time=32.177..78203.210 rows=27086 loops=1) Join Filter: ((CASE WHEN ((((((("inner".lrc + "inner".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "inner".lrc) > 60) THEN 60 ELSE (((((("inner".lrc + "inner".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "inner".lrc) END >= 60) AND (((((CASE WHEN ((((((("inner".phys + "inner".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "inner".phys) > 70) THEN 70 ELSE (((((("inner".phys + "inner".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "inner".phys) END + CASE WHEN ((((((("inner".fire + "inner".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "inner".fire) > 70) THEN 70 ELSE (((((("inner".fire + "inner".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "inner".fire) END) + CASE WHEN ((((((("inner".cold + "inner".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "inner".cold) > 70) THEN 70 ELSE (((((("inner".cold + "inner".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "inner".cold) END) + CASE WHEN ((((((("inner".poison + "inner".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "inner".poison) > 70) THEN 70 ELSE (((((("inner".poison + "inner".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "inner".poison) END) + CASE WHEN ((((((("inner".energy + "inner".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "inner".energy) > 70) THEN 70 ELSE (((((("inner".energy + "inner".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "inner".energy) END) >= 70) AND (CASE WHEN ((((((("inner".lmc + "inner".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "inner".lmc) > 15) THEN 15 ELSE (((((("inner".lmc + "inner".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "inner".lmc) END >= 15) AND CASE WHEN ((((("inner".med OR "inner".med) OR "outer".med) OR "outer".med) OR "outer".med) OR "outer".med) THEN true ELSE false END) -> Nested Loop (cost=95.54..317.67 rows=10000 width=364) (actual time=19.047..980.027 rows=10000 loops=1) -> Nested Loop (cost=70.95..93.07 rows=1000 width=273) (actual time=14.230..89.645 rows=1000 loops=1) -> Nested Loop (cost=48.88..51.00 rows=100 width=182) (actual time=10.880..17.931 rows=100 loops=1) -> Subquery Scan arms (cost=23.96..24.09 rows=10 width=91) (actual time=5.461..6.155 rows=10 loops=1) -> Limit (cost=23.96..23.99 rows=10 width=219) (actual time=5.404..5.530 rows=10 loops=1) -> Sort (cost=23.96..24.16 rows=78 width=219) (actual time=5.395..5.433 rows=10 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=78 width=219) (actual time=1.631..3.729 rows=78 loops=1) Filter: (((locn)::text = 'Arms'::text) AND ((username)::text = 'Walter'::text)) -> Materialize (cost=24.92..25.02 rows=10 width=91) (actual time=0.535..0.636 rows=10 loops=10) -> Subquery Scan legs (cost=24.79..24.92 rows=10 width=91) (actual time=5.289..5.889 rows=10 loops=1) -> Limit (cost=24.79..24.82 rows=10 width=219) (actual time=5.228..5.320 rows=10 loops=1) -> Sort (cost=24.79..25.04 rows=99 width=219) (actual time=5.219..5.255 rows=10 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=99 width=219) (actual time=0.142..3.034 rows=99 loops=1) Filter: (((locn)::text = 'Legs'::text) AND ((username)::text = 'Walter'::text)) -> Materialize (cost=22.07..22.17 rows=10 width=91) (actual time=0.035..0.069 rows=10 loops=100) -> Subquery Scan chest (cost=21.94..22.07 rows=10 width=91) (actual time=3.247..3.761 rows=10 loops=1) -> Limit (cost=21.94..21.97 rows=10 width=219) (actual time=3.151..3.226 rows=10 loops=1) -> Sort (cost=21.94..21.99 rows=20 width=219) (actual time=3.144..3.178 rows=10 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=20 width=219) (actual time=0.064..2.497 rows=37 loops=1) Filter: (((locn)::text = 'Chest'::text) AND ((username)::text = 'Walter'::text)) -> Materialize (cost=24.60..24.70 rows=10 width=91) (actual time=0.007..0.033 rows=10 loops=1000) -> Subquery Scan hands (cost=24.47..24.60 rows=10 width=91) (actual time=4.682..5.242 rows=10 loops=1) -> Limit (cost=24.47..24.50 rows=10 width=219) (actual time=4.558..4.635 rows=10 loops=1) -> Sort (cost=24.47..24.70 rows=91 width=219) (actual time=4.551..4.582 rows=10 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=91 width=219) (actual time=0.724..2.852 rows=91 loops=1) Filter: (((locn)::text = 'Hands'::text) AND ((username)::text = 'Walter'::text)) -> Materialize (cost=91.25..101.25 rows=1000 width=272) (actual time=0.003..0.242 rows=100 loops=10000) -> Nested Loop (cost=71.12..91.25 rows=1000 width=272) (actual time=10.480..17.484 rows=100 loops=1) -> Subquery Scan head (cost=24.08..24.20 rows=10 width=91) (actual time=4.450..4.931 rows=10 loops=1) -> Limit (cost=24.08..24.10 rows=10 width=219) (actual time=4.354..4.427 rows=10 loops=1) -> Sort (cost=24.08..24.28 rows=81 width=219) (actual time=4.347..4.373 rows=10 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=81 width=219) (actual time=0.400..2.930 rows=81 loops=1) Filter: (((locn)::text = 'Head'::text) AND ((username)::text = 'Walter'::text)) -> Materialize (cost=47.04..48.04 rows=100 width=181) (actual time=0.597..0.707 rows=10 loops=10) -> Nested Loop (cost=44.92..47.04 rows=100 width=181) (actual time=5.902..6.719 rows=10 loops=1) -> Subquery Scan spell (cost=21.94..22.07 rows=10 width=90) (actual time=2.289..2.304 rows=1 loops=1) -> Limit (cost=21.94..21.97 rows=10 width=219) (actual time=2.188..2.196 rows=1 loops=1) -> Sort (cost=21.94..21.99 rows=20 width=219) (actual time=2.182..2.185 rows=1 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=20 width=219) (actual time=0.055..2.106 rows=1 loops=1) Filter: (((locn)::text = 'Spell'::text) AND ((username)::text = 'Walter'::text)) -> Materialize (cost=22.98..23.08 rows=10 width=91) (actual time=3.556..4.063 rows=10 loops=1) -> Subquery Scan neck (cost=22.85..22.98 rows=10 width=91) (actual time=3.544..3.993 rows=10 loops=1) -> Limit (cost=22.85..22.88 rows=10 width=219) (actual time=3.449..3.517 rows=10 loops=1) -> Sort (cost=22.85..22.97 rows=48 width=219) (actual time=3.442..3.465 rows=10 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=48 width=219) (actual time=0.197..2.605 rows=47 loops=1) Filter: (((locn)::text = 'Neck'::text) AND ((username)::text = 'Walter'::text)) Total runtime: 87067.400 ms (59 rows)