Re: [PERFORM] Slow SQL lookup due to every field being listed in SORT KEY

2010-09-15 Thread Mason Harding
Thanks all for your help. I didn't really understand why it was sorting on every field, but it now makes sense. What I ended up doing was replacing the SELECT DISTINCT * FROM JOIN ... WHERE ... ORDER BY... LIMIT ... with SELECT * FROM ... WHERE id in (SELECT DISTINCT id FROM JOIN ...

[PERFORM] Slow SQL lookup due to every field being listed in SORT KEY

2010-09-10 Thread Mason Harding
Hi all. I Have the following query (tested in postgres 8.4 and 9.0rc1) SELECT distinct event0_.* FROM event event0_ inner join account account1_ on event0_.account_id_owner=account1_.account_id LEFT OUTER JOIN friend friendcoll2_ ON account1_.account_id=friendcoll2_.friend_account_id WHERE (event