newsfeed type query

Поиск
Список
Период
Сортировка
От Jonathan Vanasco
Тема newsfeed type query
Дата
Msg-id ACFD0156-1179-4D62-908C-77A368D39D57@2xlp.com
обсуждение исходный текст
Ответы Re: newsfeed type query  (Melvin Davidson <melvin6925@gmail.com>)
Re: newsfeed type query  (Ladislav Lenart <lenartlad@volny.cz>)
Список pgsql-general
I'm trying to upgrade some code that powers a newfeed type stream, and hoping someone can offer some insight on better
waysto structure some parts of the query 

The part that has me stumped right now...

There are several criteria for why something could appear in a stream.  for example, here are 2 handling a posting:

    * a posting by a friend
    * a posting in a group

the general way I've handled this so far has been simple:

    select * from posting where author_id in (select friend_id from friends where user_id = ?) or group_id in (select
group_idfrom memberships where user_id = ?); 

now i need to pull in the context of the match (friend, group, both), but I can't figure out how to do this cleanly.

1. if i just add 'case' statements to the select to note the origin, those subselects run again.   (ie, the same
subqueryis executed twice) 
2. if i structure this as a union (and note the origin with a string), it takes a lot more work to integrate and sort
the2 separate selects ( eg "select id, timestamp, 'by-friend'" unioned with "in-group") 

does anyone have ideas on other approaches to structuring this?












В списке pgsql-general по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Documentation Inaccuracy – Transaction Isolation
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: newsfeed type query