cypher查询的性能提升

时间:2013-09-12 09:56:00

标签: performance nosql neo4j cypher

这个密码可以更快地查询。对于2个lac记录,它需要大约30秒。

start pn=node   (10580)  
match pn--n-[rel:PAYS]-(companies)   with n,rel, companies  
match n,companies-[:BELONGS_TO]->()-->(parentInd)  
where id(parentInd) in   [10587,10657,13009,11957,10571,20980,10554,11541,11649,15339,10604,10959,10575,15302,10584,10564,10773,10597,10930,11336,10578,10674,11622,10592,14754,10611,10652,15326,11213,11429,18180,14432,12249,10785,11810,10763,12333,10944,12988,12783,12258,11778,20503,10927,16216,10552,10635,13887,12814,19424,11943,10671,10627,11202,16363,10712,12048,11128,11036,15973,10660,13083,13778,13405,13985,18313,13760,10956,11003,11472,11197,14376,10695,10644,11965,12097,13196,10719]  
with n, rel, companies  
match companies-[:LOCATED_IN]->()-->(region)  
where id(region) in    [1,2,3,4,5,6,7]  
with n, rel, companies  
match companies-[:SUB_OF]->()-->(gcbP)  
where id(gcbP) in    [13,8,11,9,10,12]  
and rel.source in ['Bloomberg','Wire','Trade BIR']  
and rel.transactionAmount > 1 and rel.transactionAmount < 9792562211034  
and rel.transactionDate > 946702800000 and rel.transactionDate < 1372651200000  
return        rel.source as DESCRIPTION, sum(rel.transactionAmount) as TRANSACTION_AMOUNT, count(*) as TRANSACTION_COUNT, "EXTERNAL" as TRANSACTION_TYPE,    n.companyParentName as D_ULTIMATE_PARENT_NAME, n.companyParentCity as d_ultimate_parent_city, n.companyParentState as d_ultimate_parent_state, n.companyParentCountry as d_ultimate_parent_country,    n.companyName as D_CUSTOMER_NAME, n.companyCity as d_customer_city, n.companyState as d_customer_state, n.companyCountry as d_customer_country,    companies.companyParentName as C_ULTIMATE_PARENT_NAME, companies.companyParentCity as c_ultimate_parent_city, companies.companyParentState as c_ultimate_parent_state, companies.companyParentCountry as c_ultimate_parent_country,    companies.companyName as C_CUSTOMER_NAME, companies.companyCity as c_customer_city, companies.companyState as c_customer_state, companies.companyCountry as c_customer_country,    n.companyIndustry as D_CUST_INDUSTRY_LEVEL_1, companies.companyIndustry as C_CUST_INDUSTRY_LEVEL_1, n.companyParentGCB as D_UP_GCP_PRIORITY, companies.companyParentGCB as C_UP_GCP_PRIORITY    ;**  

1 个答案:

答案 0 :(得分:0)

这会改善它吗?请在上面的评论中发送详细信息。

start pn=node   (10580), parentInd=node(10587,10657,13009,11957,10571,20980,10554,11541,11649,15339,10604,10959,10575,15302,10584,10564,10773,10597,10930,11336,10578,10674,11622,10592,14754,10611,10652,15326,11213,11429,18180,14432,12249,10785,11810,10763,12333,10944,12988,12783,12258,11778,20503,10927,16216,10552,10635,13887,12814,19424,11943,10671,10627,11202,16363,10712,12048,11128,11036,15973,10660,13083,13778,13405,13985,18313,13760,10956,11003,11472,11197,14376,10695,10644,11965,12097,13196,10719),
region=node(1,2,3,4,5,6,7), gcbP=node(13,8,11,9,10,12)
match companies-[:BELONGS_TO]->()-->(parentInd) 
with companies,pn
match pn--n-[rel:PAYS]-(companies)   with n,rel, companies  
match companies-[:LOCATED_IN]->()-->(region)  
with n, rel, companies  
match companies-[:SUB_OF]->()-->(gcbP)  
where 
rel.source in ['Bloomberg','Wire','Trade BIR']  
and rel.transactionAmount > 1 and rel.transactionAmount < 9792562211034  
and rel.transactionDate > 946702800000 and rel.transactionDate < 1372651200000  
return        rel.source as DESCRIPTION, sum(rel.transactionAmount) as TRANSACTION_AMOUNT, count(*) as TRANSACTION_COUNT, "EXTERNAL" as TRANSACTION_TYPE,    n.companyParentName as D_ULTIMATE_PARENT_NAME, n.companyParentCity as d_ultimate_parent_city, n.companyParentState as d_ultimate_parent_state, n.companyParentCountry as d_ultimate_parent_country,    n.companyName as D_CUSTOMER_NAME, n.companyCity as d_customer_city, n.companyState as d_customer_state, n.companyCountry as d_customer_country,    companies.companyParentName as C_ULTIMATE_PARENT_NAME, companies.companyParentCity as c_ultimate_parent_city, companies.companyParentState as c_ultimate_parent_state, companies.companyParentCountry as c_ultimate_parent_country,    companies.companyName as C_CUSTOMER_NAME, companies.companyCity as c_customer_city, companies.companyState as c_customer_state, companies.companyCountry as c_customer_country,    n.companyIndustry as D_CUST_INDUSTRY_LEVEL_1, companies.companyIndustry as C_CUST_INDUSTRY_LEVEL_1, n.companyParentGCB as D_UP_GCP_PRIORITY, companies.companyParentGCB as C_UP_GCP_PRIORITY    ;