在 Apache Ignite Sql 查询的 Update 子句中使用索引
如何选择要在这样的 UPDATE 子句上使用的索引。我需要指定 WHERE 子句中使用的列的索引?
UPDATE
DB.MY_TABLE
SET
BLOCKED = true,
HOME = '1',
WORK = '2',
WHERE
NAME = 'Me';
列“NAME”使用 INDEX_NAME 建立索引,但其他列也使用其他索引建立索引。我想做类似的事情来指定我正在使用哪个索引(这似乎只适用于 SELECT 子句):
SELECT
*
FROM
DB.MY_TABLE
USE INDEX(INDEX_NAME)
WHERE
NAME = 'Me';
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';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在撰写本文时,Ignite 执行这些查询的方式是将查询分为两部分:
SELECT
具有与原始查询中指定的相同条件。SELECT
结果并更新SET
子句中指定的每条记录。根据原始查询,通常很容易猜测
SELECT
部分的外观。就您而言,我非常确定SELECT * FROM DB.MY_TABLE WHERE Name = 'Me'
是将要执行的查询。我只需检查
EXPLAIN SELECT * FROM DB.MY_TABLE WHERE Name = 'Me'
是否使用您希望它使用的索引,然后信任系统正确执行UPDATE
。How Ignite executes these queries - at the time of writing this post - is by spliting the query into two parts:
SELECT
with the same condition as specified in the original query.SELECT
results and update each record as specified in theSET
clause.It's usually easy to guess how the
SELECT
part will look like based on the original query. In your case, I'm pretty sureSELECT * 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 theUPDATE
correctly.