Is There Alternative to Join?

5 views
Skip to first unread message

PyPy

unread,
Apr 28, 2008, 2:30:19 AM4/28/08
to Google App Engine
Hello everyone,

I'm a python newbie, and trying to write a Twitter like application on
appengine.
I'd like to create a page that shows follower's recent
entries(statuses), but I can't because the datastore has no join
function...
Please tell me how I can do it? Is there a good way?

# I've found some sample on the web, but I couldn't solve the
probrem...

Thanks for your help.

Brett Morgan

unread,
Apr 28, 2008, 2:32:01 AM4/28/08
to google-a...@googlegroups.com
An entity per person, with a list of their recent messages?

--

Brett Morgan http://brett.morgan.googlepages.com/

PyPy

unread,
Apr 28, 2008, 3:14:50 AM4/28/08
to Google App Engine
Thank you Brett.

Do you mean that I should create recent_message model and update it on
every time message posts?
How can I merge statuses of many followers? Can I paginate it?

sorry, I can't solve the probrem yet..

Thanks for your help.

Brett Morgan

unread,
Apr 28, 2008, 3:36:41 AM4/28/08
to google-a...@googlegroups.com
What I would be doing is for each person maintaining an entity with
the following:

- display name
- who they are following
- who is following them
- a merged list of the tweets of the people they are following
- a list of recent tweets

I'd be tempted to store these lists pickled in string properties,
because I don't see any need to run queries on these fields.

I'm redundantly storing both follower and followee lists. This is how
I am avoiding the need to do database joins. It does mean more work on
doing add and delete follow relationships.

This means that the updates (add a follower, delete a follower and
post a tweet) are going to be expensive, as you are updating multiple
entities. Especially in the case of posting a tweet for a popular
person. (Eggads, contention issues. Ugh)

But, on the flipside, displaying a person's page with the list of
tweets relevent to them is cheap. Which is important, because this is
the one query you want to poll regularly. Like, every second or so.

If we had background processes I'd migrate the tweet updates to a
background process with communications via a queue.

--

Brett Morgan http://brett.morgan.googlepages.com/

PyPy

unread,
Apr 28, 2008, 9:06:57 PM4/28/08
to Google App Engine
Thanks again Brett!

I understood what you mean.
I try it! thanks!

Brett Morgan

unread,
Apr 28, 2008, 9:09:40 PM4/28/08
to google-a...@googlegroups.com
There are a bunch of changes (aka complications) that probably need to
be added to ensure that you don't lose updates. So, at some point, you
are going to want to read up on transactions. =)

http://code.google.com/appengine/docs/datastore/transactions.html

--

Brett Morgan http://brett.morgan.googlepages.com/

Reply all
Reply to author
Forward
0 new messages