You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Saroj patel <sp...@dreamsoftech.com> on 2013/06/14 17:51:32 UTC

CouchDB Parameterized filtered replication Performance issue

Hi,

We have developed an iOS application with replication from: {"couchdb":"Welcome","version":"1.1.1","bigcouch":"0.4.0"}.

We are facing performance issue with the parameterized filter replication. As required we need to filter the latest 6 months of date from the Couch database which contains around 20,000 documents. The filter function written in Javascript works fine but the replication takes around 2.5 to 4 minutes. The filter is based on the data for timeSinceEpoch. 
The filter function source is as follows:
{
"_id": "_design/segmenting",
"filters": {
"by_epoch": "function(doc, req) { var beginTime = req.query.beginTime;var endTime = req.query.endTime;if (doc.timeSinceEpoch >= beginTime && doc.timeSinceEpoch <= endTime) { return true;} else {return false;}}"
}


Also read about the erlang filter function to speed up the data filter process and converted the filter function in Erlang. Tested multiple times and observed that the filter replication takes around same time. Source for Erlang design document.

{

   "_id": "_design/erlangfilter",

   "language": "erlang",

   "views": {

       "byCategoryYearMonthTest": {

           "map": "fun({Doc}) -> Doctime = proplists:get_value(<<\"timeSinceEpoch\">>, Doc, null), if Doctime > 1355630177000 -> Emit(proplists:get_value(<<\"title\">>, Doc, null), Doctime); true -> false end end."

       }

   },

   "filters": {

       "by_epoch": "fun({Doc}, {Req}) -> {Query} = proplists:get_value(<<\"query\">>, Req, null), Begintime = list_to_integer(binary_to_list(proplists:get_value(<<\"beginTime\">>, Query, null))), Doctime = proplists:get_value(<<\"timeSinceEpoch\">>, Doc, null), if Doctime > Begintime -> true; true -> false end end."

   }

}



Please verify and help with the tips/guidelines to speed up the filtered replication process.


Thanks,

Saroj Patel.

Dream Solutions, India.