Bad distributed join plan: result table shard keys do not match

主宰稳场 提交于 2020-01-05 05:12:08

问题


We are very new to memsql/mysql and we are trying to play around with a memsql installation.

It is installed on a CentOS7 virtual machine and we are running version 5.1.0 of MemSQL.

We are receiving the error from one of the queries we are attempting: ERROR 1889 (HY000): Bad distributed join plan: result table shard keys do not match. Please contact MemSQL support at support@memsql.com.

On one of our queries

We have two tables:

CREATE TABLE `MyObjects` (
    `Id` INT NOT NULL AUTO_INCREMENT,
    `Name` VARCHAR(128) NOT NULL, 
    `Description` VARCHAR(256) NULL,
    `Boolean` BIT NOT NULL,
    `Int8` TINYINT NOT NULL,
    `Int16` SMALLINT NOT NULL,
    `Int32` MEDIUMINT NOT NULL,
    `Int64` INT NOT NULL,
    `Float` DOUBLE NOT NULL,
    `DateCreated` TIMESTAMP  NOT NULL,

    SHARD KEY (`Id`),
    PRIMARY KEY (`Id`)
);

CREATE TABLE `MyObjectDetails` (
    `MyObjectId` INT,
    `Int32` MEDIUMINT NOT NULL,

    SHARD KEY (`MyObjectId`),
    INDEX (`MyObjectId`)
 );

And here is the SQL we are executing and getting the error.

memsql> SELECT mo.`Id`,mo.`Name`,mo.`Description`,mo.`Boolean`,mo.`Int8`,mo.`Int16`,
mo.`Int32`,mo.`Int64`,mo.`Float`,mo.`DateCreated`,mods.`MyObjectId`,
mods.`Int32` FROM 
    ( SELECT
        mo.`Id`,mo.`Name`,mo.`Description`,mo.`Boolean`,mo.`Int8`,
        mo.`Int16`,mo.`Int32`,mo.`Int64`,mo.`Float`,mo.`DateCreated` 
      FROM `MyObjects` mo LIMIT 10 ) AS mo 
LEFT JOIN `MyObjectDetails` mods ON mo.`Id` = mods.`MyObjectId` ORDER BY `Name` DESC;
ERROR 1889 (HY000): Bad distributed join plan: result table shard keys do not match. Please contact MemSQL support at support@memsql.com.

Does anyone know why we are receiving this error, and if there is a possible change we can make to help alleviate this issue?

The one thing we do know is it has something to do with the inner select as if I pull it out and do the join it works, however we only get 10 total rows from the join. What we are attempting is getting the top 10 from the main table and include all of the details from the right.

We also tried changing the MyObjectDetails table to have an empty SHARD KEY, but that resulted in the same error.

SHARD KEY()

We also added an auto-incrementing Id column to the details table and put the shard on that column, and yet still received the same error.

Thanks in advance for any help.

UPDATE:

I contacted MemSQL through email (huge props to their customer service by the way -- very fast response time, less than a couple hours)

But from what Mike stated I changed the table to be a REFERENCE table and removed the SHARD KEY part of the create table statement. Once I did this, I was able to run the queries. I am not 100% sure on what ramifications this will have but it fixed my issue at hand. Thanks

CREATE REFERENCE TABLE `MyObjects` (
    `Id` INT NOT NULL AUTO_INCREMENT,
    `Name` VARCHAR(128) NOT NULL, 
    `Description` VARCHAR(256) NULL,
    `Boolean` BIT NOT NULL,
    `Int8` TINYINT NOT NULL,
    `Int16` SMALLINT NOT NULL,
    `Int32` MEDIUMINT NOT NULL,
    `Int64` INT NOT NULL,
    `Float` DOUBLE NOT NULL,
    `DateCreated` TIMESTAMP  NOT NULL,

    PRIMARY KEY (`Id`)
);

回答1:


Thanks to Mike Gallegos for looking into this, adding a summary of his answer here:

The error message here is bad, but the reason for the error is that MemSQL does not currently support a distributed left join where the left side (the Limit subquery in this case) has a LIMIT operator. If you cannot rewrite the query to do the limit after the join, then you could change the MyObjects table to a reference table to work around the issue.



来源:https://stackoverflow.com/questions/39792798/bad-distributed-join-plan-result-table-shard-keys-do-not-match

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!