'Using index in Update Clause on Apache Ignite Sql Query
How do I choose a Index to use on an UPDATE Clause like this. I need to specify the index of the columns used in WHERE clause?
UPDATE
DB.MY_TABLE
SET
BLOCKED = true,
HOME = '1',
WORK = '2',
WHERE
NAME = 'Me';
The column 'NAME' is indexed with INDEX_NAME but the other columns are also indexed with other indexes. I wanted to do somenthing like that to specify which index I am using (Which seems to work just on SELECT clauses):
SELECT
*
FROM
DB.MY_TABLE
USE INDEX(INDEX_NAME)
WHERE
NAME = 'Me';
Solution 1:[1]
How Ignite executes these queries - at the time of writing this post - is by spliting the query into two parts:
SELECTwith the same condition as specified in the original query.- Iterate over the
SELECTresults and update each record as specified in theSETclause.
It's usually easy to guess how the SELECT part will look like based on the original query. In your case, I'm pretty sure SELECT * FROM DB.MY_TABLE WHERE Name = 'Me' is the query that will be executed.
I would just check that EXPLAIN SELECT * FROM DB.MY_TABLE WHERE Name = 'Me' uses the index you want it to use and then trust the system to do the UPDATE correctly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stanislav Lukyanov |
