couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sheira <karimabe...@hotmail.com>
Subject slow access to couchdb
Date Tue, 26 Feb 2013 14:36:46 GMT
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.

Mime
View raw message