Re: [PERFORM] slow self-join query

2012-03-19 Thread Kevin Grittner
Robert Poor wrote: > @kevin: I hear you. (I'm deeply steeped in Ruby on Rails and > foolishly assume that it's easy to read.) With that in mind: > > \d user_associations > id | integer | not null default > nextval('followings_id_seq'::regclass) I assume that

Re: [PERFORM] slow self-join query

2012-03-19 Thread Robert Poor
@merlin, @kevin: Thank you both -- I'll try your suggestions as soon as I get back to the mothership. @kevin: I hear you. (I'm deeply steeped in Ruby on Rails and foolishly assume that it's easy to read.) With that in mind: \d user_associations Table "public.u

Re: [PERFORM] slow self-join query

2012-03-19 Thread Kevin Grittner
Robert Poor wrote: > among users that follow leader 321, who are the most widely > followed leaders?", or more formally, find all the users that are > followers of user 321 (via inner join on F1) Of those users, > tally up their leaders so we know which leaders are most popular. It sounds like

Re: [PERFORM] slow self-join query

2012-03-19 Thread Merlin Moncure
On Sun, Mar 18, 2012 at 10:57 PM, Robert Poor wrote: > On Sun, Mar 18, 2012 at 08:30, Scott Marlowe wrote: >> Why are you joining twice to the parent table?  If you're trying to >> recurse without a with clause, then wouldn't you join the last table >> to the one before it? > > I'm FAR from being