You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by sheira <ka...@hotmail.com> on 2013/02/26 15:36:46 UTC

slow access to couchdb

Hi,

I use CouchDB in my Zend website and i'm really surprise cause I use this
code to recover the good record and it's so slow(150 records recovered in 5
minutes!)

So here is my code :

   $this->view->couchData = array();
        foreach ($this->view->arrayPostes as $k => $v) {
          $poste = PosteLogCouch::getPoste($v['poste_id']);
          $this->view->couchData[$v['poste_id']]->detailsViews =
$poste->detailsViews;
          $this->view->couchData[$v['poste_id']]->resumeViews =
$poste->resumeViews;
          $this->view->couchData[$v['poste_id']]->detailsMonthViews =
$poste->detailsMonthViews;
          $this->view->couchData[$v['poste_id']]->resumeMonthViews =
$poste->resumeMonthViews;
          $this->view->couchData[$v['poste_id']]->appliants =
$poste->appliants;
          $this->view->couchData[$v['poste_id']]->monthAppliants =
$poste->monthAppliants;
        }

and here is my PosteLogCouch Class:

<?php
class PosteLogCouch {
  function detailsView($id) {
    $poste = self::getPoste($id);
    $poste->detailsViews++;
    $poste->detailsMonthViews++;
  }
  function resumeView($id) {
    $poste = self::getPoste($id);
    $poste->resumeViews++;
    $poste->resumeMonthViews++;
  }
  
  function appliant($id) {
    $poste = self::getPoste($id);
    $poste->appliants++;
    $poste->monthAppliants++;
  }

  function getPoste($id) {
    $couchClient = Zend_registry::get('couchdb_client');
    try {
      $couchClient->asCouchDocuments();
      $annonce = $couchClient->getDoc('Poste'.$id);
    } catch (couchException $e) {
      if ($e->getCode() == '404') {
        $annonce = new Cwl_Couch_Model($couchClient);
        $annonce->_id = 'Poste'.$id;
      }
    }
    self::checkMonth($annonce);
    return $annonce;
  }
  protected function checkMonth($poste) {
    $month = date('n');
    if ($poste->month != $month) {
      $poste->month = $month;
      $poste->detailsMonthViews = 0;
      $poste->resumeMonthViews = 0;
      $poste->monthAppliants = 0;
      return false;
    }
    return true;
  }
}

Can we please help me to solve this problem?

Thanks in advance!



--
View this message in context: http://couchdb-development.1959287.n2.nabble.com/slow-access-to-couchdb-tp7583314.html
Sent from the CouchDB Development mailing list archive at Nabble.com.

Re: slow access to couchdb

Posted by Robert Newson <rn...@apache.org>.
You managed to subscribe to the dev mailing list, I'm sure you can
figure out how to subscribe to our user mailing list :)

On 26 February 2013 20:19, sheira <ka...@hotmail.com> wrote:
> Thanks, but I can't send my message I always have this message error :"Domain
> starts with dot"
>
>
>
>
> --
> View this message in context: http://couchdb-development.1959287.n2.nabble.com/slow-access-to-couchdb-tp7583314p7583317.html
> Sent from the CouchDB Development mailing list archive at Nabble.com.

Re: slow access to couchdb

Posted by sheira <ka...@hotmail.com>.
Thanks, but I can't send my message I always have this message error :"Domain
starts with dot"




--
View this message in context: http://couchdb-development.1959287.n2.nabble.com/slow-access-to-couchdb-tp7583314p7583317.html
Sent from the CouchDB Development mailing list archive at Nabble.com.

Re: slow access to couchdb

Posted by Randall Leeds <ra...@gmail.com>.
You might have better luck on the user mailing list: user@couchdb.apache.org.

On Tue, Feb 26, 2013 at 6:36 AM, sheira <ka...@hotmail.com> wrote:
> Hi,
>
> I use CouchDB in my Zend website and i'm really surprise cause I use this
> code to recover the good record and it's so slow(150 records recovered in 5
> minutes!)
>
> So here is my code :
>
>    $this->view->couchData = array();
>         foreach ($this->view->arrayPostes as $k => $v) {
>           $poste = PosteLogCouch::getPoste($v['poste_id']);
>           $this->view->couchData[$v['poste_id']]->detailsViews =
> $poste->detailsViews;
>           $this->view->couchData[$v['poste_id']]->resumeViews =
> $poste->resumeViews;
>           $this->view->couchData[$v['poste_id']]->detailsMonthViews =
> $poste->detailsMonthViews;
>           $this->view->couchData[$v['poste_id']]->resumeMonthViews =
> $poste->resumeMonthViews;
>           $this->view->couchData[$v['poste_id']]->appliants =
> $poste->appliants;
>           $this->view->couchData[$v['poste_id']]->monthAppliants =
> $poste->monthAppliants;
>         }
>
> and here is my PosteLogCouch Class:
>
> <?php
> class PosteLogCouch {
>   function detailsView($id) {
>     $poste = self::getPoste($id);
>     $poste->detailsViews++;
>     $poste->detailsMonthViews++;
>   }
>   function resumeView($id) {
>     $poste = self::getPoste($id);
>     $poste->resumeViews++;
>     $poste->resumeMonthViews++;
>   }
>
>   function appliant($id) {
>     $poste = self::getPoste($id);
>     $poste->appliants++;
>     $poste->monthAppliants++;
>   }
>
>   function getPoste($id) {
>     $couchClient = Zend_registry::get('couchdb_client');
>     try {
>       $couchClient->asCouchDocuments();
>       $annonce = $couchClient->getDoc('Poste'.$id);
>     } catch (couchException $e) {
>       if ($e->getCode() == '404') {
>         $annonce = new Cwl_Couch_Model($couchClient);
>         $annonce->_id = 'Poste'.$id;
>       }
>     }
>     self::checkMonth($annonce);
>     return $annonce;
>   }
>   protected function checkMonth($poste) {
>     $month = date('n');
>     if ($poste->month != $month) {
>       $poste->month = $month;
>       $poste->detailsMonthViews = 0;
>       $poste->resumeMonthViews = 0;
>       $poste->monthAppliants = 0;
>       return false;
>     }
>     return true;
>   }
> }
>
> Can we please help me to solve this problem?
>
> Thanks in advance!
>
>
>
> --
> View this message in context: http://couchdb-development.1959287.n2.nabble.com/slow-access-to-couchdb-tp7583314.html
> Sent from the CouchDB Development mailing list archive at Nabble.com.