如何增加mongodb的表现 [英] How ti increase mongodb performance
问题描述
我是MongoDB的新手。
我有这样的文件集合:
{
_id:ObjectId( 58204f60536d1a27736d512b),
last_name:Vinaykumar,
university_name:Osmania University,
job_483:1,
xiith_mark:0,
id:3305775,
first_name:V,
course_name:Diploma,
institute_name_string:Govt.Polytechnic,Kothagudem ,
profile_percentage:60,
xiith_mark_type:百分比,
xth_mark_type:百分比,
date_of_birth:1995年3月11日,
xth_mark:0,
last_login:1379565790,
百分比:76,
job_details:[
{
status:NumberLong(0),
applied_date:NumberLong(1476703354),
contact_viwed_status:0,
label_name:[],
questionnaire_status : 0,
batch_id:null,
owner_type:搜索,
call_letter:null,
owner_id:NumberLong(465)
},
{
status:NumberLong(0),
applied_date:NumberLong(1477051963),
contact_viwed_status:0,
label_name :[],
questionnaire_status:0,
batch_id:null,
owner_type:搜索,
call_letter:null,
owner_id:NumberLong(482)
},
{
status:NumberLong(0),
applied_date:NumberLong(1477052973),
contact_viwed_status:0,
label_name:[],
questionnaire_status:0,
batch_id:null,
owner_type:搜索,
call_letter:null,
owner_id:NumberLong(483)
}
],
branch_name:Electrical& Electronics,
candidate_state_name:Andhra Pradesh,
candidate_city_name_string:Andhra Pradesh-other,
10:10,
12:12 ,
性别:男性,
fw_id:FW15651132,
cgpa:0,
picture_path:,
hq_passout_year:2013
},
..........
...... .......
我需要从这个数据库中找到带有方面数的数据。
**需要关注以下方面字段**
1.job_details.status
2.job_details.label_name
3.job_details.contact_viwed_status
4.candidate_city_name_string
5.course_name
6.hq_passout_year
7.branch_name
8.candidate_sublocation_name_string
9.skill
总匹配数和有限的数据
我为每个方面和一个查询单独查询为了数量和一个数据查询
总计9 + 1 + 1 = 11个查询
**查询是**
我的尝试:
查询是 <对于job_details.status和job_details.label_name以及job_details.contact_viwed_status这样的
facet查询是这样的
< pre lang = Python>
db .Response.aggregate([
{$ match:{$ and:[{job_details.owner_id:428},
{job_details.owner_type:'搜索'}]} },
{$ unwind:$ job_details},
{$ group:{_ id:$ job_details.status,count:{$ sum: 1}}}
])
其他6个方面的查询是这样的
db.Response.aggregate([{$ and:[{job_details.owner_id:428},{job_details.owner_type:'searching'}]},
{$ group:{_ id:$ candidate_city_name_string,count:{$ sum:1}}}])
**查询收集数据**
db.Response.aggregate([
{$ and:[{job_details.owner_id:428} {job_details.owner_type:'searching'}]},
{$ limit:25},``
{$ skip:0},
{$ unwind:$ job_details}])
查询收集总数
< pre> db.Response.find({$ and:[{job_details.owner_id:428},{job_details.owner_type:'searching'}}})。count()
总计3 + 9 + 1 + 1 = 11个查询
所以表现非常非常低。可以在这里制作这个11 api到中心代码单个api或者我怎样才能提高性能。
请帮忙。
match:{
和:[{ job_details.owner_id:428},
{job_details.owner_type:'搜索'}}}},
{
unwind:
I'm new using MongoDB.
I have a collection of documents like this:
{ "_id" : ObjectId("58204f60536d1a27736d512b"), "last_name" : "Vinaykumar", "university_name" : "Osmania University", "job_483" : 1, "xiith_mark" : 0, "id" : "3305775", "first_name" : "V", "course_name" : "Diploma", "institute_name_string" : "Govt.Polytechnic,Kothagudem", "profile_percentage" : 60, "xiith_mark_type" : "Percentage", "xth_mark_type" : "Percentage", "date_of_birth" : "11-March-1995", "xth_mark" : 0, "last_login" : 1379565790, "percentage" : 76, "job_details" : [ { "status" : NumberLong(0), "applied_date" : NumberLong(1476703354), "contact_viwed_status" : 0, "label_name" : [ ], "questionnaire_status" : 0, "batch_id" : null, "owner_type" : "searches", "call_letter" : null, "owner_id" : NumberLong(465) }, { "status" : NumberLong(0), "applied_date" : NumberLong(1477051963), "contact_viwed_status" : 0, "label_name" : [ ], "questionnaire_status" : 0, "batch_id" : null, "owner_type" : "searches", "call_letter" : null, "owner_id" : NumberLong(482) }, { "status" : NumberLong(0), "applied_date" : NumberLong(1477052973), "contact_viwed_status" : 0, "label_name" : [ ], "questionnaire_status" : 0, "batch_id" : null, "owner_type" : "searches", "call_letter" : null, "owner_id" : NumberLong(483) } ], "branch_name" : "Electrical & Electronics", "candidate_state_name" : "Andhra Pradesh", "candidate_city_name_string" : "Andhra Pradesh-other", "10" : 10, "12" : 12, "gender" : "Male", "fw_id" : "FW15651132", "cgpa" : 0, "picture_path" : "", "hq_passout_year" : 2013 },
..........
.............
I need to find data from this db with facet count .
**Need facet count for following fields**
1.job_details.status
2.job_details.label_name
3.job_details.contact_viwed_status
4.candidate_city_name_string
5.course_name
6.hq_passout_year
7.branch_name
8.candidate_sublocation_name_string
9.skill
And total matching count and data with limit
I did separate query for each facet and one query for total count and one query for data
Total 9+1+1=11 querys
**Query's are**
What I have tried:
Query's are
facet query's for job_details.status and job_details.label_name and job_details.contact_viwed_status did like this
<pre lang="Python">
db.Response.aggregate([ {"$match":{"$and":[{"job_details.owner_id" : 428}, {"job_details.owner_type" : 'searches'}]}}, {"$unwind": "$job_details" }, {"$group": {"_id":"$job_details.status","count": {"$sum": 1 }} } ])
other 6 facet query's like this
db.Response.aggregate([ {"$and":[{"job_details.owner_id" : 428},{"job_details.owner_type" : 'searches'}]}, {"$group": {"_id":"$candidate_city_name_string","count": {"$sum": 1 }}}] )
**query for collecting data**
db.Response.aggregate([ {"$and":[{"job_details.owner_id" : 428}{"job_details.owner_type" : 'searches'}]}, {"$limit":25},`` { "$skip":0} , {"$unwind":"$job_details"}])
query for collecting total count
<pre>db.Response.find({"$and":[{"job_details.owner_id" : 428},{"job_details.owner_type" : 'searches'}]}).count()
Total 3+9+1+1=11 Querys
So performance is very very low . Is possible to make this 11 api to`enter code here` single api or how can i improve the performance.
please help.
match":{"
and":[{"job_details.owner_id" : 428}, {"job_details.owner_type" : 'searches'}]}}, {"
unwind": "
这篇关于如何增加mongodb的表现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!