streamy=# EXPLAIN ANALYZE streamy-# SELECT i.itemid, i.title, i.thumbnail, i.date streamy-# FROM index.feedtopic f, index.feedtopic f2, pre."userToItems" uti, play.tbxmlcontentitems i2, play.tbxmlcontentitems i LEFT OUTER JOIN pre.items p streamy-# ON (p.itemid=i.itemid) streamy-# WHERE streamy-# i2.itemid='318e4942-4590-48d1-87fe-a2b092aaa3f2' AND streamy-# f2.resourceid=i2.resourceid AND streamy-# f.topicid=f2.topicid AND streamy-# i.resourceid=f.resourceid AND streamy-# uti.userid='9fd80e57-5af8-43a3-91e5-bcaad5338967' AND i.itemid!=uti.itemid AND streamy-# i.thumbnail != '' AND streamy-# (now()-'7 day'::interval) Sort (cost=262008.22..262387.00 rows=151512 width=124) (actual time=1929.301..1929.301 rows=0 loops=1) Sort Key: (p.score IS NULL), p.score, i.date -> Nested Loop (cost=216998.26..223851.31 rows=151512 width=124) (actual time=1929.285..1929.285 rows=0 loops=1) Join Filter: ("inner".itemid <> "outer".itemid) -> Bitmap Heap Scan on "userToItems" uti (cost=5.36..40.24 rows=390 width=16) (actual time=0.256..1.159 rows=388 loops=1) Recheck Cond: (userid = '9fd80e57-5af8-43a3-91e5-bcaad5338967'::uniqueidentifier) -> Bitmap Index Scan on "userToItems_idx1" (cost=0.00..5.36 rows=390 width=0) (actual time=0.218..0.218 rows=388 loops=1) Index Cond: (userid = '9fd80e57-5af8-43a3-91e5-bcaad5338967'::uniqueidentifier) -> Materialize (cost=216992.90..217000.67 rows=777 width=124) (actual time=4.967..4.967 rows=0 loops=388) -> Nested Loop (cost=22.68..216992.12 rows=777 width=124) (actual time=1926.726..1926.726 rows=0 loops=1) Join Filter: ("outer".resourceid = "inner".resourceid) -> Nested Loop Left Join (cost=0.00..208014.22 rows=26534 width=140) (actual time=0.119..1823.307 rows=26345 loops=1) -> Seq Scan on tbxmlcontentitems i (cost=0.00..48425.08 rows=26534 width=136) (actual time=0.054..1489.911 rows=26345 loops=1) Filter: ((thumbnail <> ''::text) AND ((now() - '7 days'::interval) < date)) -> Index Scan using items_idx on items p (cost=0.00..6.00 rows=1 width=20) (actual time=0.008..0.008 rows=0 loops=26345) Index Cond: (p.itemid = "outer".itemid) -> Materialize (cost=22.68..22.83 rows=15 width=16) (actual time=0.001..0.001 rows=0 loops=26345) -> Nested Loop (cost=6.81..22.66 rows=15 width=16) (actual time=0.131..0.131 rows=0 loops=1) -> Nested Loop (cost=0.00..11.58 rows=1 width=4) (actual time=0.128..0.128 rows=0 loops=1) -> Index Scan using tbxmlcontentitems_pkey on tbxmlcontentitems i2 (cost=0.00..6.01 rows=1 width=16) (actual time=0.078..0.081 rows=1 loops=1) Index Cond: (itemid = '318e4942-4590-48d1-87fe-a2b092aaa3f2'::uniqueidentifier) -> Index Scan using feedtopic_idx on feedtopic f2 (cost=0.00..5.56 rows=1 width=20) (actual time=0.042..0.042 rows=0 loops=1) Index Cond: (f2.resourceid = "outer".resourceid) -> Bitmap Heap Scan on feedtopic f (cost=6.81..10.99 rows=7 width=20) (never executed) Recheck Cond: (f.topicid = "outer".topicid) -> Bitmap Index Scan on feedtopic_idx (cost=0.00..6.81 rows=7 width=0) (never executed) Index Cond: (f.topicid = "outer".topicid) Total runtime: 1929.480 ms (29 rows)