我有一个带有文档样式存储的orientdb数据库。 我有一个MyDocument类,有大约300,000条记录,以循环方式存储(没有自定义聚类策略)。
我有一个数字字段,以yyyyMMdd的方式告诉我存储日,它不是唯一的SBtree索引。
直到我查询如下:
select from MyDocument where publishDay=20151101
效果很好:我每天大约有100条记录。
如果我使用范围疼痛开始:
select from MyDocument where publishDay between 20151101 and 20151102
如果我从控制台执行此查询,则返回0条记录。
如果我从网络应用程序执行此操作,则说
"fetched more than 50000 records: to speed up the execution, create an index or change the query to use an existent index"
但我已经有了一个索引,所以在特定日期我似乎无法做更多的查询。 也是一个技巧,如:
select * from inputdocument where publishday = 20150102 or publishday = 20150101
BTW我使用版本2.0.15
我做错了吗?我是否通过这种用法达到了orientdb的极限?
答案 0 :(得分:1)
我试图用这个小的osql脚本在OrientDB 2.0.15中重现你的数据库:
create class MyDocument extends V;
create property MyDocument.publishDay integer;
create vertex MyDocument set publishDay = 20151101;
create vertex MyDocument set publishDay = 20151101;
create vertex MyDocument set publishDay = 20151101;
create vertex MyDocument set publishDay = 20151101;
create vertex MyDocument set publishDay = 20151101;
create vertex MyDocument set publishDay = 20151101;
create vertex MyDocument set publishDay = 20151102;
create vertex MyDocument set publishDay = 20151102;
create vertex MyDocument set publishDay = 20151102;
create vertex MyDocument set publishDay = 20151102;
create vertex MyDocument set publishDay = 20151102;
create vertex MyDocument set publishDay = 20151102;
create vertex MyDocument set publishDay = 20151103;
create vertex MyDocument set publishDay = 20151103;
create vertex MyDocument set publishDay = 20151103;
create vertex MyDocument set publishDay = 20151103;
create vertex MyDocument set publishDay = 20151103;
create vertex MyDocument set publishDay = 20151103;
create vertex MyDocument set publishDay = 20151104;
create vertex MyDocument set publishDay = 20151104;
create vertex MyDocument set publishDay = 20151104;
create vertex MyDocument set publishDay = 20151104;
create vertex MyDocument set publishDay = 20151104;
create vertex MyDocument set publishDay = 20151104;
create vertex MyDocument set publishDay = 20151105;
create vertex MyDocument set publishDay = 20151105;
create vertex MyDocument set publishDay = 20151105;
create vertex MyDocument set publishDay = 20151105;
create vertex MyDocument set publishDay = 20151105;
create vertex MyDocument set publishDay = 20151105;
create vertex MyDocument set publishDay = 20151106;
create vertex MyDocument set publishDay = 20151106;
create vertex MyDocument set publishDay = 20151106;
create vertex MyDocument set publishDay = 20151106;
create vertex MyDocument set publishDay = 20151106;
create vertex MyDocument set publishDay = 20151106;
create index MyDocument.publishDay NOTUNIQUE;
我将属性“publishDay”声明为整数,并在“publishDay”上创建了一个NOTUNIQUE索引。
并且您的查询有效
也按索引搜索
您的架构有什么不同吗?
答案 1 :(得分:1)
我认为您已经定义了一个HASHINDEX,根据定义,它不能处理范围。尝试使用NOTUNIQUE索引(SBTree算法)