Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 63944 invoked from network); 29 Apr 2008 21:15:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Apr 2008 21:15:49 -0000 Received: (qmail 88612 invoked by uid 500); 29 Apr 2008 21:15:50 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 88589 invoked by uid 500); 29 Apr 2008 21:15:50 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 88578 invoked by uid 99); 29 Apr 2008 21:15:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Apr 2008 14:15:50 -0700 X-ASF-Spam-Status: No, hits=3.5 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of guby.mail@gmail.com designates 74.125.46.153 as permitted sender) Received: from [74.125.46.153] (HELO yw-out-1718.google.com) (74.125.46.153) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Apr 2008 21:15:05 +0000 Received: by yw-out-1718.google.com with SMTP id 5so121565ywm.0 for ; Tue, 29 Apr 2008 14:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to:in-reply-to:content-type:mime-version:subject:date:references:x-mailer; bh=4ud3XNPiIGqlR7Cql12SIvSuL+WWZLdPy0oRm22oxXU=; b=EqGGfw7RUkGg0GS1C41TJvxEx9iJhkrIzicwLvcdeGNiZj5TpItSFU7fPFJRBBWrrqBjGCpn31a6gmPMud6hRoQgo2w+TCzjEC6435u9rhhm47bj50EwzC7679LTmipllk2r8lviTozteInXvMrWxDfqQ3EPUhO2CfVymdWvRRI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type:mime-version:subject:date:references:x-mailer; b=h91159ddgTyKKNoSRi9UHF4m1vvnB9PegJ9K6ZGSwhYhgUfbm32bcbZoyjlLCmVPKw54/jr6Z2omcf2okHE+cYdZDh2x0TJV/87JuFOoOo/fVnkk+XLHBfQBXIAbEFZTI47lljnU/KSGk8qDTC0lWVUEhPaP7+Q60//u9Ti7b5U= Received: by 10.150.82.27 with SMTP id f27mr280384ybb.149.1209503702226; Tue, 29 Apr 2008 14:15:02 -0700 (PDT) Received: from ?192.168.1.100? ( [200.89.150.124]) by mx.google.com with ESMTPS id g5sm598525wra.33.2008.04.29.14.14.59 (version=SSLv3 cipher=OTHER); Tue, 29 Apr 2008 14:15:01 -0700 (PDT) Message-Id: <2C59BE6D-C831-4CD7-BBE0-F894CA96F617@gmail.com> From: Guby To: couchdb-user@incubator.apache.org In-Reply-To: Content-Type: multipart/alternative; boundary=Apple-Mail-3--731795187 Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Updating views on save Date: Tue, 29 Apr 2008 18:13:58 -0300 References: <94947A5A-28C0-4ED2-98F4-0C780A9970FA@apache.org> <43B3557F-C8DB-4580-A70E-8B5DCAF94C91@gmail.com> <1DBCBFC4-6A33-4DAC-8981-7286773A623E@gmail.com> <4624B2E1-C462-4191-BFBC-417267659399@apache.org> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-3--731795187 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hm... On my server I just noticed CouchDB had started 14 instances of the DbUpdateNotificationProcess! Is this normal, and in case, why so many? And why do they all keep running when the CouchDB is somewhat idle and doesn't need them at all? Best regards Sebastian On Apr 28, 2008, at 1:55 PM, Guby wrote: > Added to wiki: http://wiki.apache.org/couchdb/ > RegeneratingViewsOnUpdate > Edit as you see fit. > > S > > > On Apr 28, 2008, at 1:14 PM, Guby wrote: > >> Sure! >> That makes more sense than having it here in the mailinglist :) >> >> S >> >> On Apr 28, 2008, at 12:58 PM, Jan Lehnardt wrote: >> >>> >>> On Apr 28, 2008, at 17:18, Guby wrote: >>>> I am very happy with the way this discussion turned out! >>>> Now I have written a tiny ruby script that updates the views for >>>> every tenth document update and at most once every second under >>>> heavy updates. >>>> Here on my development machine it uses about 1.2 mb of ram, and I >>>> can live with that. >>>> >>>> I'll include it here in case somebody reads this discussion in >>>> the future and needs a similar script. >>> >>> Would you mind putting it on the Wiki? For the obvious benefits :) >>> >>> Good work there, >>> >>> Cheers >>> Jan >>> -- >>> >>> >>>> >>>> >>>> Thanks again for all the help and for a great database! >>>> >>>> Best regards >>>> Sebastian >>>> >>>> >>>> ********************************** >>>> >>>> CONFIG: couch.ini: >>>> add line: >>>> DbUpdateNotificationProcess=/PATH/TO/view_updater.rb >>>> >>>> ********************************** >>>> >>>> SCRIPT: view_updater.rb >>>> >>>> #!/usr/bin/ruby >>>> >>>> ### >>>> # CONF >>>> ### >>>> >>>> # The smallest amount of changed documents before the views are >>>> updated >>>> MIN_NUM_OF_CHANGED_DOCS = 10 >>>> >>>> # URL to the DB on the CouchDB server >>>> # Only supports one database at the moment as that is what I need >>>> # Should be easy to improve for several databases if needed >>>> URL = "http://localhost:5984/kleio" >>>> >>>> # Set the minimum pause between calls to the database >>>> PAUSE = 1 # seconds >>>> >>>> # One for each design document >>>> VIEWS = ["feed/to_check", >>>> "feed_entries/list_for_user_by_feed", >>>> "subscription/number_of_subscriptions", >>>> "subscription_requests/request", >>>> "user/by_email", >>>> "couch_object_has_many_relations/related_documents"] >>>> >>>> >>>> >>>> >>>> ### >>>> # "MAIN LOOP" >>>> ### >>>> >>>> run = true >>>> number_of_changed_docs = 0 >>>> >>>> threads = [] >>>> >>>> # Updates the views >>>> threads << Thread.new do >>>> >>>> while run do >>>> >>>> if number_of_changed_docs >= MIN_NUM_OF_CHANGED_DOCS >>>> >>>> number_of_changed_docs = 0 >>>> >>>> VIEWS.each do |view| >>>> `curl #{URL}/_view/#{view}?count=0` >>>> end >>>> >>>> end >>>> >>>> sleep PAUSE >>>> >>>> end >>>> >>>> end >>>> >>>> # Receives the update notification from CouchDB >>>> threads << Thread.new do >>>> >>>> while run do >>>> >>>> update_call = gets >>>> >>>> # When CouchDB exits the script gets called with >>>> # a never ending series of nil >>>> if update_call == nil >>>> run = false >>>> else >>>> number_of_changed_docs += 1 >>>> end >>>> >>>> end >>>> >>>> end >>>> >>>> # Good bye >>>> threads.each {|thr| thr.join} >>>> >>>> >>> >> > --Apple-Mail-3--731795187--