是否有更快捷的方式在CouchDB
上创建视图?
我的数据是这样的:
{"docs":[{
"c_custkey": 1,
"c_name": "Customer#000000001",
"c_address": "IVhzIApeRb",
"c_city": "MOROCCO 0",
"c_nation": "MOROCCO",
"c_region": "AFRICA",
"lineorder": [{
"lo_orderkey": 164711,
"lo_linenumber": 1,
"lo_custkey": 1,
"lo_partkey": 82527,
"lo_suppkey": 1848,
"lo_quantity": 34,
"lo_extendedprice": 5132368,
"lo_revenue": 2816872,
"orderdate": [{
"d_datekey": 19920426,
"d_date": "April 26, 1992",
"d_dayofweek": "Monday",
"d_month": "April",
"d_year": 1992,
"d_yearmonthnum": 199204,
}],
"part": [{
"p_partkey": 82527,
"p_name": "steel tomato",
"p_mfgr": "MFGR#4",
"p_category": "MFGR#45",
"p_brand1": "MFGR#452",
}],
"supplier": [{
"s_city": "MOZAMBIQU8",
"s_nation": "MOZAMBIQUE",
"s_region": "AFRICA",
}]
}, {
"lo_orderkey": 164711,
"lo_linenumber": 2,
"lo_custkey": 1,
"lo_partkey": 26184,
"lo_suppkey": 1046,
"lo_orderdate": 19920426,
"lo_quantity": 15,
"lo_extendedprice": 1665270,
"orderdate": [{
"d_datekey": 19920426,
"d_date": "April 26, 1992",
"d_dayofweek": "Monday",
"d_month": "April",
"d_year": 1992,
"d_yearmonthnum": 199204,
}],
"part": [{
"p_partkey": 26184,
"p_name": "chartreuse green",
"p_mfgr": "MFGR#2",
"p_category": "MFGR#23",
"p_brand1": "MFGR#2329",
}],
"supplier": [{
"s_suppkey": 1046,
"s_city": "SAUDI ARA2",
"s_nation": "SAUDI ARABIA",
"s_region": "MIDDLE EAST",
}]
},...
我正在使用FUTON
以这种方式创建视图,但需要30分钟:
地图功能:
function(doc)
{
var c_city=doc.c_city
var c_nation=doc.c_nation
if (c_nation=="UNITED STATES"){
for each (lineorder in doc.lineorder) {
for each (supplier in lineorder.supplier){
var s_city=supplier.s_city
var s_nation=supplier.s_nation
}
if (s_nation=="UNITED STATES"){
for each (orderdate in lineorder.orderdate) {
var d_year=orderdate.d_year
}
if (d_year>=1992 && d_year<=1997){
emit({d_year:d_year,c_city:c_city,s_city:s_city},lineorder.lo_revenue);
}
}
}
}
}
减少功能:“ - _sum”
我的数据库有2 GB这类数据。
答案 0 :(得分:0)
这显然不是你的真实观点(lineorder
与lineorders
并且没有lo_revenue
),所以我不会浪费时间来表达它。相反,让我说对于2GB数据集,谁知道每个文档有多少lineorders
次迭代,30分钟并不令人惊讶。