Re: [GENERAL] Help Optimizing a Summary Query

2014-12-11 Thread David G Johnston
Robert DiFalco wrote > I have users, friends, and friend_requests. I need a query that > essentially > returns a summary containing: > > * user (name, imageURL, bio, ...) > * Friend status (relative to an active user) >* Is the user a friend of the active user? >* Has the u

Re: [GENERAL] Help Optimizing a Summary Query

2014-12-11 Thread Arthur Silva
On Thu, Dec 11, 2014 at 6:52 PM, Robert DiFalco wrote: > Thanks Arthur. I don't think there is as big a different between BIGINT > and INTEGER as you think there is. In fact with an extended filesystem you > might not see any difference at all. > > As I put in the first emal I am using a GIST ind

Re: [GENERAL] Help Optimizing a Summary Query

2014-12-11 Thread Robert DiFalco
Thanks Arthur. I don't think there is as big a different between BIGINT and INTEGER as you think there is. In fact with an extended filesystem you might not see any difference at all. As I put in the first emal I am using a GIST index on user.name. I was really more interested in the LEFT OUTER J

Re: [GENERAL] Help Optimizing a Summary Query

2014-12-09 Thread Arthur Silva
On Tue, Dec 9, 2014 at 4:18 PM, Robert DiFalco wrote: > I'm sorry, I missed a JOIN on the second variation. It is: > > SELECT u.id, u.name, u.imageURL, u.bio, >CASE > WHEN f.friend_id IS NOT NULL THEN 'isFriend' > WHEN s.to_id IS NOT NULL THEN 'hasSentRequest' > WHEN r.to_id

Re: [GENERAL] Help Optimizing a Summary Query

2014-12-09 Thread Robert DiFalco
I'm sorry, I missed a JOIN on the second variation. It is: SELECT u.id, u.name, u.imageURL, u.bio, CASE WHEN f.friend_id IS NOT NULL THEN 'isFriend' WHEN s.to_id IS NOT NULL THEN 'hasSentRequest' WHEN r.to_id IS NOT NULL THEN 'hasReceivedRequest' ELSE 'none' END AS 'f