文件是同一个。数据量大概在100万条左右; 第一条执行大概4分钟,使用top命令cpu占用大概在30%到90% USING PERIODIC COMMIT 1000 LOAD CSV FROM ‘file:///2018rel/rel_2018_00_00.csv’ AS line FIELDTERMINATOR ‘γ’ WITH line,coalesce(toFloat(line[2]),toFloat(0)) AS profit ,coalesce(toFloat(line[3]),toFloat(0)) AS tax MATCH (n:Company{name:line[0]}) SET n.profit2018=coalesce(n.profit2018,toFloat(0))+profit+tax return count(); 第二条执行大概2个小时,使用top命令cpu占用大概在1%到12% USING PERIODIC COMMIT 1000 LOAD CSV FROM ‘file:///2018rel/rel_2018_00_00.csv’ AS line FIELDTERMINATOR ‘γ’ WITH line,coalesce(toFloat(line[2]),toFloat(0)) AS expense ,coalesce(toFloat(line[3]),toFloat(0)) AS tax MATCH (n:Company{name:line[1]}) SET n.expense2018=coalesce(n.expense2018,toFloat(0))+expense+tax return count(); 语句唯一的差别是。第一条是读取第一列的数据line[0]作为MATCH的条件,第二条是读取第二列的数据line[1]作为MATCH的条件。 还有,目前是给name加了唯一约束。 感觉很头疼,求帮助。
通过LOAD CSV导入数据,同一个文件两条差不多的语句效率相差极大