QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=15274618.96..15274619.21 rows=100 width=636) (actual time=55918.65..55936.40 rows=100 loops=1) -> Sort (cost=15274618.96..15275544.88 rows=370370 width=636) (actual time=55918.65..55936.26 rows=101 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=163.94..14798762.27 rows=370370 width=636) (actual time=2482.59..53290.43 rows=27086 loops=1) Join Filter: ((CASE WHEN ((((((("outer".lrc + "outer".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "inner".lrc) > 60) THEN 60 ELSE (((((("outer".lrc + "outer".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "outer".lrc) + "inner".lrc) END >= 60) AND (((((CASE WHEN ((((((("outer".phys + "outer".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "inner".phys) > 70) THEN 70 ELSE (((((("outer".phys + "outer".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "outer".phys) + "inner".phys) END + CASE WHEN ((((((("outer".fire + "outer".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "inner".fire) > 70) THEN 70 ELSE (((((("outer".fire + "outer".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "outer".fire) + "inner".fire) END) + CASE WHEN ((((((("outer".cold + "outer".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "inner".cold) > 70) THEN 70 ELSE (((((("outer".cold + "outer".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "outer".cold) + "inner".cold) END) + CASE WHEN ((((((("outer".poison + "outer".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "inner".poison) > 70) THEN 70 ELSE (((((("outer".poison + "outer".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "outer".poison) + "inner".poison) END) + CASE WHEN ((((((("outer".energy + "outer".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "inner".energy) > 70) THEN 70 ELSE (((((("outer".energy + "outer".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "outer".energy) + "inner".energy) END) >= 70) AND (CASE WHEN ((((((("outer".lmc + "outer".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "inner".lmc) > 15) THEN 15 ELSE (((((("outer".lmc + "outer".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "outer".lmc) + "inner".lmc) END >= 15)) -> Nested Loop (cost=142.03..1266974.73 rows=1000000 width=546) (actual time=2481.54..25983.11 rows=1000000 loops=1) Join Filter: CASE WHEN ((((("inner".med OR "inner".med) OR "inner".med) OR "inner".med) OR "inner".med) OR "outer".med) THEN true ELSE false END -> Subquery Scan legs (cost=24.79..24.82 rows=10 width=219) (actual time=2.64..2.77 rows=10 loops=1) -> Limit (cost=24.79..24.82 rows=10 width=219) (actual time=2.63..2.66 rows=10 loops=1) -> Sort (cost=24.79..25.04 rows=99 width=219) (actual time=2.63..2.64 rows=11 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=99 width=219) (actual time=0.07..2.34 rows=99 loops=1) Filter: ((locn = 'Legs'::character varying) AND (username = 'Walter'::character varying)) -> Materialize (cost=125747.75..125747.75 rows=100000 width=455) (actual time=247.90..467.73 rows=100000 loops=10) -> Nested Loop (cost=117.24..125747.75 rows=100000 width=455) (actual time=164.03..2285.17 rows=100000 loops=1) -> Subquery Scan hands (cost=24.47..24.50 rows=10 width=219) (actual time=2.56..2.70 rows=10 loops=1) -> Limit (cost=24.47..24.50 rows=10 width=219) (actual time=2.55..2.58 rows=10 loops=1) -> Sort (cost=24.47..24.70 rows=91 width=219) (actual time=2.54..2.56 rows=11 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=91 width=219) (actual time=0.15..2.31 rows=91 loops=1) Filter: ((locn = 'Hands'::character varying) AND (username = 'Walter'::character varying)) -> Materialize (cost=12514.07..12514.07 rows=10000 width=364) (actual time=16.15..78.55 rows=10000 loops=10) -> Nested Loop (cost=92.77..12514.07 rows=10000 width=364) (actual time=26.32..138.43 rows=10000 loops=1) -> Subquery Scan arms (cost=23.96..23.99 rows=10 width=219) (actual time=2.23..2.37 rows=10 loops=1) -> Limit (cost=23.96..23.99 rows=10 width=219) (actual time=2.22..2.25 rows=10 loops=1) -> Sort (cost=23.96..24.16 rows=78 width=219) (actual time=2.21..2.23 rows=11 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=78 width=219) (actual time=0.22..2.02 rows=78 loops=1) Filter: ((locn = 'Arms'::character varying) AND (username = 'Walter'::character varying)) -> Materialize (cost=1269.97..1269.97 rows=1000 width=273) (actual time=2.41..3.12 rows=1000 loops=10) -> Nested Loop (cost=68.81..1269.97 rows=1000 width=273) (actual time=4.71..22.54 rows=1000 loops=1) -> Nested Loop (cost=46.89..150.84 rows=100 width=182) (actual time=3.49..4.95 rows=100 loops=1) -> Subquery Scan head (cost=24.08..24.10 rows=10 width=219) (actual time=2.11..2.19 rows=10 loops=1) -> Limit (cost=24.08..24.10 rows=10 width=219) (actual time=2.10..2.12 rows=10 loops=1) -> Sort (cost=24.08..24.28 rows=81 width=219) (actual time=2.10..2.10 rows=11 loops=1) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=81 width=219) (actual time=0.09..1.90 rows=81 loops=1) Filter: ((locn = 'Head'::character varying) AND (username = 'Walter'::character varying)) -> Subquery Scan neck (cost=22.82..22.84 rows=10 width=219) (actual time=0.14..0.22 rows=10 loops=10) -> Limit (cost=22.82..22.84 rows=10 width=219) (actual time=0.14..0.16 rows=10 loops=10) -> Sort (cost=22.82..22.93 rows=47 width=219) (actual time=0.14..0.14 rows=11 loops=10) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=47 width=219) (actual time=0.06..1.25 rows=47 loops=1) Filter: ((locn = 'Neck'::character varying) AND (username = 'Walter'::character varying)) -> Subquery Scan chest (cost=21.91..21.94 rows=10 width=219) (actual time=0.02..0.10 rows=10 loops=100) -> Limit (cost=21.91..21.94 rows=10 width=219) (actual time=0.01..0.03 rows=10 loops=100) -> Sort (cost=21.91..21.96 rows=19 width=219) (actual time=0.01..0.02 rows=11 loops=100) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=19 width=219) (actual time=0.03..1.10 rows=37 loops=1) Filter: ((locn = 'Chest'::character varying) AND (username = 'Walter'::character varying)) -> Subquery Scan spell (cost=21.91..21.94 rows=10 width=219) (actual time=0.01..0.01 rows=1 loops=1000000) -> Limit (cost=21.91..21.94 rows=10 width=219) (actual time=0.00..0.00 rows=1 loops=1000000) -> Sort (cost=21.91..21.96 rows=19 width=219) (actual time=0.00..0.00 rows=1 loops=1000000) Sort Key: itemid -> Seq Scan on suit_item (cost=0.00..21.51 rows=19 width=219) (actual time=0.04..0.43 rows=1 loops=1) Filter: ((locn = 'Spell'::character varying) AND (username = 'Walter'::character varying)) Total runtime: 55941.97 msec (57 rows)