[ https://issues.apache.org/jira/browse/IGNITE-6663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16264494#comment-16264494 ]
ASF GitHub Bot commented on IGNITE-6663: ---------------------------------------- GitHub user gg-shq opened a pull request: https://github.com/apache/ignite/pull/3086 IGNITE-6663: SQL: optimize primary key equality lookup You can merge this pull request into a Git repository by running: $ git pull https://github.com/gridgain/apache-ignite ignite-6663 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/ignite/pull/3086.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3086 ---- commit 292fffbbfd992441812680030ee9b0ab1d4bc74f Author: gg-shq <kshiro...@gridgain.com> Date: 2017-11-23T15:47:50Z IGNITE-6663: Implement find(..., key, key) via findOne(), not via find(first, last, ...). Implement equals() and hashCode() for GridH2SearchRowAdapter. ---- > SQL: optimize primary key equality lookup > ----------------------------------------- > > Key: IGNITE-6663 > URL: https://issues.apache.org/jira/browse/IGNITE-6663 > Project: Ignite > Issue Type: Task > Components: sql > Reporter: Vladimir Ozerov > Assignee: Kirill Shirokov > Labels: performance > Fix For: 2.4 > > > H2 perform every index search through {{BaseIndex.find}} method. It contains > both {{first}} and {{last}} rows. If condition looks like {{attr = ?}}, then > both bounds are the same. When this call is propagated to our {{BPlusTree}}, > then two index lookups occur: > - Lower bound: {{BPlusTree#findInsertionPoint}} > - Upper bound: {{BPlusTree.ForwardCursor#findUpperBound}} > This is done for a reason because we do not know in advance how many elements > are in between the bounds, so one lookup + scan is not an option in general > case. But in case of PK lookup with equality condition, when we know in > advance that only one row will be returned, this leads to additional > unnecessary comparisons. > Suggested fix: > 1) Make sure that all rows in {{GridH2PlainRowFactory}} has correct > {{equals}} implementation. > 2) Inside {{H2TreeIndex#find}}: if this is PK index (see constructor args) > and {{lower.equals(upper)}}, then use {{BPlusTree.findOne}} instead of > {{BPlusTree.find}}. -- This message was sent by Atlassian JIRA (v6.4.14#64029)