You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a table Person and two columns firstName, lastName. I have a composite index on two columns (firstName, lastName) as well. My query is SELECT * FROM Person WHERE firstName IN ("FirstName1", "FirstName2") AND lastName="LastName1". H2 doesn't use the index. In my case Y IN(..) will produce far less rows than X=?.
I decided to have a look on source code. I have found a method org.h2.index.IndexCursor#prepare. There is such a piece of code in the method: if (isStart || isEnd) { // an X=? condition will produce less rows than // an X IN(..) condition inColumn = null; inList = null; inResult = null; }
I agree that X=? condition will produce less rows than X IN(..). But I doesn't agree that X=? will produce less rows than Y IN (..). This condition excludes IN values from Row.
I changed in debug mode isStart and isEnd values to false and H2 will start to use my index.
How can I manage this situation?
Does H2 have statistics like Oracle?
The text was updated successfully, but these errors were encountered:
I have a table Person and two columns firstName, lastName. I have a composite index on two columns (firstName, lastName) as well. My query is SELECT * FROM Person WHERE firstName IN ("FirstName1", "FirstName2") AND lastName="LastName1". H2 doesn't use the index. In my case Y IN(..) will produce far less rows than X=?.
I decided to have a look on source code. I have found a method org.h2.index.IndexCursor#prepare. There is such a piece of code in the method:
if (isStart || isEnd) { // an X=? condition will produce less rows than // an X IN(..) condition inColumn = null; inList = null; inResult = null; }
I agree that X=? condition will produce less rows than X IN(..). But I doesn't agree that X=? will produce less rows than Y IN (..). This condition excludes IN values from Row.
I changed in debug mode isStart and isEnd values to false and H2 will start to use my index.
The text was updated successfully, but these errors were encountered: