Re: [orientdb] Re: BUG?:inconsitent behavior of query with/without index
Hi Andrey, I'm still working on a test case, but in contrast to my real application I can't reproduce the problem. But as far as I can tell, there IS a problem. What I found so far is the following: I have let's say 3 Classes A, B, C, where C is derived from B and B from A. The index that makes the problems is created on an attribute of A, called status (an enum, with values like NONE and READY). The corresponding OrientDB property that I create is of type STRING. Now I add instances of B and C to the database, let's say 2000 each, 1000 of them with status READY and 1000 with status NONE. So we have 1000 x B with status NONE, 1000 x B with status READY, 1000 x C with status NONE and 1000 x C with status READY. If I execute: {select count(*) from B where status='READY'} it will return 2000 (which is correct). If I execute: {select count(*) from C where status='READY'} and @class='C' it will return 1000 (which is correct). If I execute: {select count(*) from C where status='READY'} it will return 2000 (wrong)! If I execute: {select * from C where status in ['READY']} it will return NO row (using IN for a single value of course makes no sense, it's just to show the problem). If I execute: {select * from C where status in ['READY'] limit 1001} it will return ONE row! It looks like the query of C using IN together with an index returns also instances of B which are filtered out afterwards? That would explain why the last query returns one row: because the 1000 x B + 1 is the first C row. If I remove the index or use a query that avoids using the index, everything works fine (but slower of course). I know, it looks strange and I can't isolate it in a separate test case, but maybe you get an idea about why this happens. Kind regards, Markus -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [orientdb] Re: BUG?:inconsitent behavior of query with/without index
I just managed to make the problem reproducible: package com.axxelia; import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; public class OrientDBTest { public static void main(String [] args) { OGlobalConfiguration.CACHE_LEVEL1_ENABLED.setValue(false); OObjectDatabaseTx db = new OObjectDatabaseTx(memory:test); if(!db.exists()) { db.create(); System.out.println(db.create()); } db.getEntityManager().registerEntityClasses(com.axxelia.domain); try { TestCase4.testCase(db); } finally { db.close(); } } } package com.axxelia; import com.axxelia.domain.*; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; import java.util.List; public class TestCase4 { public static void testCase(OObjectDatabaseTx db) { ItemWorkStep idt1 = new ItemWorkStep(); idt1.setStatus(Status.NONE); db.save(idt1); ItemWorkStep idt2 = new ItemWorkStep(); idt2.setStatus(Status.STARTED); db.save(idt2); WorkOrderWorkStep idt3 = new WorkOrderWorkStep(); idt3.setStatus(Status.NONE); db.save(idt3); WorkOrderWorkStep idt4 = new WorkOrderWorkStep(); idt4.setStatus(Status.STARTED); db.save(idt4); ListWorkOrderWorkStep subs; ListODocument counts; counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM ItemWorkStep WHERE status IN ['NONE', 'STARTED'])); assert ((Long) (counts.iterator().next().field(count))) == 4; counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status IN ['NONE', 'STARTED'])); assert ((Long) (counts.iterator().next().field(count))) == 2; db.command(new OCommandSQL(CREATE PROPERTY AdaptiveTask.status STRING)).execute(); counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status IN ['NONE', 'STARTED'])); assert ((Long) (counts.iterator().next().field(count))) == 2; /** * create the index */ db.command(new OCommandSQL(CREATE INDEX AdaptiveTask.status ON AdaptiveTask (status) NOTUNIQUE)).execute(); /** * huh!! those two tests fail. if you remove the index above, they will succeed!!! */ counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status='NONE')); assert ((Long) (counts.iterator().next().field(count))) == 1; counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status in ['NONE'])); assert ((Long) (counts.iterator().next().field(count))) == 1; } } package com.axxelia.domain; public class AdaptiveTask { private Status status; public Status getStatus() { return status; } public void setStatus(Status status) { this.status = status; } } package com.axxelia.domain; public class ItemWorkStep extends AdaptiveTask {} package com.axxelia.domain; public class WorkOrderWorkStep extends ItemWorkStep {} -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [orientdb] Re: BUG?:inconsitent behavior of query with/without index
Cool ! I will fix it, at Monday. On Fri, Jan 10, 2014 at 5:14 PM, Markus Menner markus.men...@googlemail.com wrote: I just managed to make the problem reproducible: package com.axxelia; import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; public class OrientDBTest { public static void main(String [] args) { OGlobalConfiguration.CACHE_LEVEL1_ENABLED.setValue(false); OObjectDatabaseTx db = new OObjectDatabaseTx(memory:test); if(!db.exists()) { db.create(); System.out.println(db.create()); } db.getEntityManager().registerEntityClasses(com.axxelia.domain); try { TestCase4.testCase(db); } finally { db.close(); } } } package com.axxelia; import com.axxelia.domain.*; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; import java.util.List; public class TestCase4 { public static void testCase(OObjectDatabaseTx db) { ItemWorkStep idt1 = new ItemWorkStep(); idt1.setStatus(Status.NONE); db.save(idt1); ItemWorkStep idt2 = new ItemWorkStep(); idt2.setStatus(Status.STARTED); db.save(idt2); WorkOrderWorkStep idt3 = new WorkOrderWorkStep(); idt3.setStatus(Status.NONE); db.save(idt3); WorkOrderWorkStep idt4 = new WorkOrderWorkStep(); idt4.setStatus(Status.STARTED); db.save(idt4); ListWorkOrderWorkStep subs; ListODocument counts; counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM ItemWorkStep WHERE status IN ['NONE', 'STARTED'])); assert ((Long) (counts.iterator().next().field(count))) == 4; counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status IN ['NONE', 'STARTED'])); assert ((Long) (counts.iterator().next().field(count))) == 2; db.command(new OCommandSQL(CREATE PROPERTY AdaptiveTask.status STRING)).execute(); counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status IN ['NONE', 'STARTED'])); assert ((Long) (counts.iterator().next().field(count))) == 2; /** * create the index */ db.command(new OCommandSQL(CREATE INDEX AdaptiveTask.status ON AdaptiveTask (status) NOTUNIQUE)).execute(); /** * huh!! those two tests fail. if you remove the index above, they will succeed!!! */ counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status='NONE')); assert ((Long) (counts.iterator().next().field(count))) == 1; counts = db.query(new OSQLSynchQuery(SELECT count(*) FROM WorkOrderWorkStep WHERE status in ['NONE'])); assert ((Long) (counts.iterator().next().field(count))) == 1; } } package com.axxelia.domain; public class AdaptiveTask { private Status status; public Status getStatus() { return status; } public void setStatus(Status status) { this.status = status; } } package com.axxelia.domain; public class ItemWorkStep extends AdaptiveTask {} package com.axxelia.domain; public class WorkOrderWorkStep extends ItemWorkStep {} -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Best regards, Andrey Lomakin. Orient Technologies the Company behind OrientDB -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [orientdb] Re: BUG?:inconsitent behavior of query with/without index
Hi We have tests like this one com.orientechnologies.orient.test.database.auto.IndexTest#testIndexInNotUniqueIndex and have no issues for a long time. Could you provide more specific test case ? On Sat, Jan 4, 2014 at 5:48 PM, Markus Menner markus.men...@googlemail.comwrote: Hi Luca, Sure. However, I can't download 1.6.3. I filled out the form, but it doesn't send me the download link via email. Regards, Markus On Saturday, 4 January 2014 08:54:51 UTC+1, Markus Menner wrote: Hi guys, I'm using OrientDB 1.6.2 with the ObjectDatabase. I noticed following strange behavior of queries: 1.) Class A, with let's say property status, which is a string. Add some instances to the db, which contain either NONE or STARTED in the status. SELECT * FROM A WHERE status IN ['NONE', 'STARTED'] will produce the correct result (those instances). 2.) Create a property of type String and an index (NOTUNIQUE) on it. SELECT * FROM A WHERE status IN ['NONE', 'STARTED'] will produce an empty result! However SELECT * FROM A WHERE status='NONE' will produce an NON-empty result with the correct instances (and I presume also uses the index). If you just remove the index (leave the attribute), everything works as expected. So somehow the IN doesn't work as soon as there is an index on a property? Kind regards, Markus -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Best regards, Andrey Lomakin. Orient Technologies the Company behind OrientDB -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[orientdb] Re: BUG?:inconsitent behavior of query with/without index
Hi Luca, Sure. However, I can't download 1.6.3. I filled out the form, but it doesn't send me the download link via email. Regards, Markus On Saturday, 4 January 2014 08:54:51 UTC+1, Markus Menner wrote: Hi guys, I'm using OrientDB 1.6.2 with the ObjectDatabase. I noticed following strange behavior of queries: 1.) Class A, with let's say property status, which is a string. Add some instances to the db, which contain either NONE or STARTED in the status. SELECT * FROM A WHERE status IN ['NONE', 'STARTED'] will produce the correct result (those instances). 2.) Create a property of type String and an index (NOTUNIQUE) on it. SELECT * FROM A WHERE status IN ['NONE', 'STARTED'] will produce an empty result! However SELECT * FROM A WHERE status='NONE' will produce an NON-empty result with the correct instances (and I presume also uses the index). If you just remove the index (leave the attribute), everything works as expected. So somehow the IN doesn't work as soon as there is an index on a property? Kind regards, Markus -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.