Re: [PERFORM] Forcing postgresql to use an index

2009-09-10 Thread Eugene Morozov
Grzegorz Jaƛkiewicz writes: > Learn it to not generate with "WITH IN (subq)", is this can be quite > slow on postgresql. Use joins instead. OK, I've split the query in two (can't make Django to generate JOIN in this case) and it always uses index now. This immediately opened road for other optim

Re: [PERFORM] Forcing postgresql to use an index

2009-09-08 Thread Eugene Morozov
Scott Marlowe writes: > On Tue, Sep 8, 2009 at 8:12 AM, Eugene Morozov wrote: > OK, you need to look a little deeper at what's happening here. The > pgsql query planner looks at a lot of things to decide if to use seq > scan or and index. If you look at your row estimates ver

[PERFORM] Forcing postgresql to use an index

2009-09-08 Thread Eugene Morozov
Hello, I have a following query (autogenerated by Django) SELECT activity_activityevent.id, activity_activityevent.user_id, activity_activityevent.added_on FROM activity_activityevent WHERE activity_activityevent.user_id IN ( SELECT U0.user_id FROM profile U0 INNER JOIN profile_frien