Re: [PERFORM] Advise needed for a join query with a where conditional

2015-12-12 Thread Jeff Janes
On Thu, Dec 10, 2015 at 8:38 PM, ankur_adwyze wrote: > Hi Folks, > > I am a newbie to this mailing list. Tried searching the forum but didn't > find something similar to the problem I am facing. > > Background: > I have a Rails app with Postgres db. For certain reports, I have to join > multiple t

Re: [PERFORM] Advise needed for a join query with a where conditional

2015-12-11 Thread Jim Nasby
On 12/10/15 10:38 PM, ankur_adwyze wrote: I have a Rails app with Postgres db. For certain reports, I have to join multiple tables. However, certain join queries are dog slow and I am wondering if I am missing any index. My guess is that the planner is coming up with a bad estimate. Please pos

Re: [PERFORM] Advise needed for a join query with a where conditional

2015-12-10 Thread ankur_adwyze
Note that the inner query is fast (takes only about 0.5 second): SELECT "fb_ad_groups"."id" FROM "fb_ad_groups" WHERE "fb_ad_groups"."id" IN (SELECT "fb_ad_groups"."id" FROM "fb_ad_groups" INNER JOIN "custom_tags_fb_ad_groups" ON "fb_ad_groups"."id" = "custom_tags_fb_ad_groups"."fb_ad_group_id" IN

[PERFORM] Advise needed for a join query with a where conditional

2015-12-10 Thread ankur_adwyze
Hi Folks, I am a newbie to this mailing list. Tried searching the forum but didn't find something similar to the problem I am facing. Background: I have a Rails app with Postgres db. For certain reports, I have to join multiple tables. However, certain join queries are dog slow and I am wonderin