incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "paul jobs" <webjog...@gmail.com>
Subject notifications heavy writes - really slow views
Date Sat, 10 Jan 2009 23:01:03 GMT
schema
class Notification(Document):
    unread = BooleanField(default=True)
    activity = TextField()
    appname = TextField()
    image = TextField()
    type = TextField(default='notification')
    fromuser = TextField()
    touser = TextField()
    link = TextField()
    message = TextField()
    created = DateTimeField(default=datetime.datetime.now())
    time =TimeField(default=datetime.datetime.now())
    date = DateField(default=datetime.date.today()

def savenotifications(fromuser, tousers, link, message, activity, image,
appname, *args, **kwargs):
    for touser in tousers:
        if fromuser == touser:continue
        notidoc = Notification( fromuser = fromuser,touser=touser,
link=link, message=message, activity=activity, image = image, appname =
appname)
        notidoc.store(fbcouchdb)
    for touser in tousers:
        r=fbcouchdb.view('_view/pop/unread',key=str(touser), count=1)
        for i in r:i

I ever try to prepare the views when some one gets a new notifications by
precalling the view unread

but whenever i do  getnotification it is really slow.. And the page doesnt
open forever. Anyways to make couchdb usable with this db? the situation is
that notifications are constantly inserted into the db all the time as
things happen to the user in real time. is this not a good use case for
couchdb

    def getnotifications(self, all=False):
        try:
            from couchmodel import fbcouchdb
            if not all:
                return [ (x.id, x.value) for x in
fbcouchdb.view('_view/pop/unre
ad',key=str(self.uid), count=5) ]
            else:
                return [ (x.id, x.value) for x in
fbcouchdb.view('_view/pop/noti
fications',key=str(self.uid)) ]
        except:return[]

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message