pg_9_4_Fast QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=7.00..79.41 rows=25 width=268) (actual time=0.568..1.348 rows=25 loops=1) -> Nested Loop Left Join (cost=7.00..250829.09 rows=86592 width=268) (actual time=0.567..1.343 rows=25 loops=1) -> Nested Loop Left Join (cost=6.71..223240.48 rows=86592 width=275) (actual time=0.565..1.320 rows=25 loops=1) -> Nested Loop Left Join (cost=6.42..195651.87 rows=86592 width=282) (actual time=0.556..1.198 rows=25 loops=1) Join Filter: (wos.statusid = std.statusid) -> Nested Loop Left Join (cost=6.42..194351.80 rows=86592 width=273) (actual time=0.411..1.022 rows=25 loops=1) -> Nested Loop Left Join (cost=6.29..180268.60 rows=86592 width=253) (actual time=0.409..0.999 rows=25 loops=1) -> Nested Loop Left Join (cost=6.00..152702.85 rows=86592 width=234) (actual time=0.402..0.891 rows=25 loops=1) -> Nested Loop Left Join (cost=5.71..124414.37 rows=86592 width=223) (actual time=0.390..0.601 rows=25 loops=1) Join Filter: (wo.workorderid = wo_queue.workorderid) Rows Removed by Join Filter: 25 -> Nested Loop Left Join (cost=4.69..123112.82 rows=86592 width=208) (actual time=0.042..0.230 rows=25 loops=1) -> Nested Loop Left Join (cost=4.56..109029.62 rows=86592 width=205) (actual time=0.039..0.208 rows=25 loops=1) -> Nested Loop Left Join (cost=4.41..83014.38 rows=86592 width=205) (actual time=0.037..0.187 rows=25 loops=1) -> Nested Loop Left Join (cost=4.27..68290.31 rows=86592 width=205) (actual time=0.035..0.163 rows=25 loops=1) -> Merge Join (cost=4.12..36022.21 rows=86592 width=205) (actual time=0.030..0.123 rows=25 loops=1) Merge Cond: (wo.workorderid = wos.workorderid) -> Index Scan Backward using workorder_pk on workorder wo (cost=0.42..18645.63 rows=302945 width=157) (actual time=0.013..0.048 rows=25 loops=1) Filter: isparent -> Index Scan Backward using workorderstates_fk1_idx on workorderstates wos (cost=0.42..15538.74 rows=86592 width=136) (actual time=0.012..0.034 rows=25 loops=1) Filter: (statusid = 1) -> Index Only Scan using wotoprojects_fk1_idx on wotoprojects wtp (cost=0.15..0.29 rows=8 width=8) (actual time=0.001..0.001 rows=0 loops=25) Index Cond: (workorderid = wo.workorderid) Heap Fetches: 0 -> Index Only Scan using sitedefinition_fk2_idx on sitedefinition (cost=0.14..0.16 rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=25) Index Cond: (siteid = wo.siteid) Heap Fetches: 0 -> Index Scan using sdorganization_pk on sdorganization (cost=0.14..0.29 rows=1 width=16) (actual time=0.000..0.000 rows=0 loops=25) Index Cond: (sitedefinition.siteid = org_id) -> Index Scan using categorydefinition_pk on categorydefinition cd (cost=0.14..0.15 rows=1 width=19) (actual time=0.000..0.000 rows=0 loops=25) Index Cond: (wos.categoryid = categoryid) -> Materialize (cost=1.02..2.67 rows=1 width=23) (actual time=0.013..0.014 rows=1 loops=25) -> Hash Right Join (cost=1.02..2.67 rows=1 width=23) (actual time=0.324..0.341 rows=1 loops=1) Hash Cond: (qd.queueid = wo_queue.queueid) -> Seq Scan on queuedefinition qd (cost=0.00..1.46 rows=46 width=23) (actual time=0.154..0.161 rows=46 loops=1) -> Hash (cost=1.01..1.01 rows=1 width=16) (actual time=0.158..0.158 rows=1 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 1kB -> Seq Scan on workorder_queue wo_queue (cost=0.00..1.01 rows=1 width=16) (actual time=0.154..0.155 rows=1 loops=1) -> Index Scan using aaauser_pk on aaauser ti (cost=0.29..0.32 rows=1 width=19) (actual time=0.010..0.011 rows=1 loops=25) Index Cond: (wos.ownerid = user_id) -> Index Scan using aaauser_pk on aaauser aau (cost=0.29..0.31 rows=1 width=19) (actual time=0.003..0.003 rows=1 loops=25) Index Cond: (wo.requesterid = user_id) -> Index Scan using prioritydefinition_pk on prioritydefinition pd (cost=0.14..0.15 rows=1 width=20) (actual time=0.000..0.000 rows=0 loops=25) Index Cond: (wos.priorityid = priorityid) -> Materialize (cost=0.00..1.19 rows=1 width=17) (actual time=0.006..0.006 rows=1 loops=25) -> Seq Scan on statusdefinition std (cost=0.00..1.19 rows=1 width=17) (actual time=0.142..0.145 rows=1 loops=1) Filter: (statusid = 1) Rows Removed by Filter: 14 -> Index Scan using sduser_fk1_idx on sduser (cost=0.29..0.31 rows=1 width=9) (actual time=0.003..0.004 rows=1 loops=25) Index Cond: (wo.requesterid = userid) -> Index Scan using sduser_fk1_idx on sduser sduser_onbehalfof (cost=0.29..0.31 rows=1 width=9) (actual time=0.000..0.000 rows=0 loops=25) Index Cond: (wo.oboid = userid) Planning time: 36.746 ms Execution time: 1.710 ms (54 rows)