• ADADADADAD

    MySQL Cluster的结果顺序是怎样的[ mysql数据库 ]

    mysql数据库 时间:2024-11-26 22:07:38

    作者:文/会员上传

    简介:

    最近搭建了MySQL Cluster的环境来学习,发现一个很有意思的现象,在不加order by的情况下,返回的结果顺序是随机的,每次都不一样,如下[@more@]mysql> select * from test_ndb limit

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    最近搭建了MySQL Cluster的环境来学习,发现一个很有意思的现象,在不加order by的情况下,返回的结果顺序是随机的,每次都不一样,如下

    [@more@]

    mysql> select * from test_ndb limit 3;
    +---+-------+
    | i | a |
    +---+-------+
    | 5 | test5 |
    | 1 | test1 |
    | 2 | test2 |
    +---+-------+
    3 rows in set (0.05 sec)

    mysql> select * from test_ndb limit 3;
    +---+-------+
    | i | a |
    +---+-------+
    | 7 | test7 |
    | 3 | test3 |
    | 6 | test6 |
    +---+-------+
    3 rows in set (0.03 sec)

    mysql> select * from test_ndb limit 3;
    +---+-------+
    | i | a |
    +---+-------+
    | 5 | test5 |
    | 1 | test1 |
    | 2 | test2 |
    +---+-------+
    3 rows in set (0.05 sec)

    我想这应试与NDB的存储方式有关吧,NDB实际上将表的数据用hash算法分布到不同结点,NDB表的主键并不像InnoDB一样是聚集索引,而是hash索引,所以在取数据的时候每次的顺序就不一定一样了。

    MySQL Cluster的结果顺序是怎样的.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: mysqlcluster