当前位置:网站首页>Neo4j---性能优化
Neo4j---性能优化
2022-06-30 03:03:00 【抹香鲸之海】
一、基础调优
1、cql语句性能排查
(1)EXPLAIN + 执行的cql语句
仅仅查看执行计划,不执行语句
(2)PROFILE + 执行的cql语句
运行语句,并全程监督资源使用情况
(3)查看索引创建情况
:schema
2、 使用建议
1)相关主键创建索引 语法格式CREATE INDEX ON: 标签(待查字段);
①模式索引:模式索引和关系数据库中的索引很相似, 每一个索引会对应一个标签和一组属性,无论是更新还是删除节点,索引都会自动更新或者删除,因此该种创建索引的方式更适用。
注意:索引状态是ONLINE才能生效,否则刚刚建的索引是无效的。
2)创建唯一索引,避免数据入库检查,造成性能浪费(可以在入库之前校验好数据的完整性和唯一性)CREATE CONSTRAINT ON (n:ResNode) ASSERT n.id IS UNIQUE;
3)create 和 merge的区别 MERGE命令是CREATE命令和MATCH命令的组合。 MERGE = CREATE + MATCH 故新增节点尽量避免merge;
4)不必要的数据,尽可能早的过滤掉,减少后期处理的数据量;
5)避免返回整个节点,返回其中需要的数据。
二、优化neo4j配置文件
对neo4j.conf文件并进行相应修改。通过添加jvm虚拟环境可以提高数据库的查询速度,即取消neo4j配置文件中关于dbms.memory.heap.initial_size=512m;dbms.memory.heap.max_size=512m两行的注释,并做合适的修改(最大堆内存越大越好,但是要小于机器的物理内存)。
三、进阶方案解决性能问题
1、合理引入中间件
eg:涉及内容关键字检索,可以使用elasticSearch,避免直接从neo4j搜索查询,若能结合redis及内存缓存获取详细资源信息,搜索只返回主键,还能进一步提交查询效率,用户体验大幅提升;
涉及大量查询可以使用redis作为neo4j的一个缓存库,既能提高性能,也能避免neo4j的资源消耗;
2、分库存储,充分利用neo4j的图存储和查询特点,neo4j中只提供图的存储和查询功能,节点的属性信息保存在mongodb(或其他NoSql 数据库中—字段可以直接存储)进行关联查询,各取所长,充分利优势,优化性能;
3、使用neo4j企业版高可用、集群方案。
边栏推荐
- Federal learning: dividing non IID samples by Dirichlet distribution
- 链接乱码转义符
- Redis+AOP怎么自定义注解实现限流
- Shell counts all strings before the last occurrence of a string
- How can redis+aop customize annotations to achieve flow restriction
- 2022 underground coal mine electrical test and underground coal mine electrical simulation test
- 2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
-   Difference from spaces
- How to set password complexity and timeout exit function in Oracle
- Auto. JS learning notes 15:ui interface basics of autojs Chapter 2
猜你喜欢

【直播笔记0629】 并发编程二:锁

How to use redis to realize the like function

Federal learning: dividing non IID samples by Dirichlet distribution

Cross domain, CORS, jsonp

Mysql提取表字段中的字符串

Simple custom MVC optimization

简单自定义MVC优化

中断操作:AbortController学习笔记

How to prevent duplicate submission under concurrent requests

Use compose to realize the effect of selecting movie seats by panning tickets
随机推荐
mysqldump原理
Jvxetable增加自定义按钮
The rigorous judgment of ID number is accurate to the last place in the team
Reasons for MySQL master-slave database synchronization failure
Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
Differences between comparable and comparator
【实战技能】如何撰写敏捷开发文档
C # basic learning (XIII) | breakpoint debugging
Raki's notes on reading paper: neighborhood matching network for entity alignment
GTK interface programming (II): key components
自定义MVC的使用
Prompt learning a blood case caused by a space
LeetCode 3. Longest substring without duplicate characters
浅谈IDEA的优化和使用
How to realize remote collaborative office, keep this strategy!
原生JS怎么生成九宫格
  Difference from spaces
O & M (20) make and start USB flash disk and install win10
Multi card server usage
The Oracle main program is deleted, but the data is on another hard disk. Can I import the data again?