MariaDB、PBXT 和神秘的查询结果

发布于 2024-09-30 11:03:53 字数 3335 浏览 6 评论 0原文

首先,这是表格:

CREATE TABLE `outlet_tags` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `importer_id` int(11) NOT NULL,
  `outlet_id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `postcode` varchar(15) DEFAULT NULL,
  `tag_set` varchar(45) DEFAULT NULL,
  `tag_type` varchar(45) DEFAULT NULL,
  `tag_details` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_report_outlet_tags_1` (`importer_id`),
  KEY `fk_report_outlet_tags_2` (`outlet_id`),
  KEY `outlet_tag_set` (`tag_set`),
  KEY `outlet_tag_type` (`tag_type`),
  KEY `outlet_tag_details` (`tag_details`),
  CONSTRAINT `fk_report_outlet_tags_1` FOREIGN KEY (`importer_id`) REFERENCES `importers` (`id`),
  CONSTRAINT `fk_report_outlet_tags_2` FOREIGN KEY (`outlet_id`) REFERENCES `outlets` (`id`)
) ENGINE=PBXT DEFAULT CHARSET=utf8;

任何人都可以解释为什么字段值会根据以下查询中使用的条件而变化吗?如果引擎是玛丽亚,就不会发生这种情况。

select * from outlet_tags where code=1503 and outlet_id=407 limit 3;
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| id   | importer_id | outlet_id | code | postcode | tag_set | tag_type        | tag_details    |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
|  222 |           1 |       407 | 1503 | XXX XXX  | outlet  | Make up         | Make up        |
|  675 |           1 |       407 | 1503 | XXX XXX  | outlet  | Approved Status | Approved       |
| 1619 |           1 |       407 | 1503 | XXX XXX  | outlet  | Retail Area     | No Retail Area |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
3 rows in set (0.00 sec)

select * from outlet_tags where code=1503 and importer_id=1 limit 3;
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| id   | importer_id | outlet_id | code | postcode | tag_set | tag_type        | tag_details    |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
|  222 |           1 |       407 | 1503 | XXX XXX  | outlet  | Make up         | Make up        |
|  675 |           1 |       407 | 1503 | XXX XXX  | outlet  | Approved Status | Approved       |
| 1619 |           1 |       407 | 1503 | XXX XXX  | outlet  | Retail Area     | No Retail Area |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
3 rows in set (0.00 sec)

select * from outlet_tags where importer_id=1 and outlet_id=407 limit 3;
+------+-------------+-----------+------+----------+---------+----------+-------------+
| id   | importer_id | outlet_id | code | postcode | tag_set | tag_type | tag_details |
+------+-------------+-----------+------+----------+---------+----------+-------------+
|  222 |           1 |       407 | 1503 | NULL     | NULL    | NULL     | NULL        |
|  675 |           1 |       407 | 1503 | NULL     | NULL    | NULL     | NULL        |
| 1619 |           1 |       407 | 1503 | NULL     | NULL    | NULL     | NULL        |
+------+-------------+-----------+------+----------+---------+----------+-------------+
3 rows in set (0.00 sec)

更新:从 MariaDB 5.5 开始 PBXT 已作为存储引擎

First of all, here's the table:

CREATE TABLE `outlet_tags` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `importer_id` int(11) NOT NULL,
  `outlet_id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `postcode` varchar(15) DEFAULT NULL,
  `tag_set` varchar(45) DEFAULT NULL,
  `tag_type` varchar(45) DEFAULT NULL,
  `tag_details` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_report_outlet_tags_1` (`importer_id`),
  KEY `fk_report_outlet_tags_2` (`outlet_id`),
  KEY `outlet_tag_set` (`tag_set`),
  KEY `outlet_tag_type` (`tag_type`),
  KEY `outlet_tag_details` (`tag_details`),
  CONSTRAINT `fk_report_outlet_tags_1` FOREIGN KEY (`importer_id`) REFERENCES `importers` (`id`),
  CONSTRAINT `fk_report_outlet_tags_2` FOREIGN KEY (`outlet_id`) REFERENCES `outlets` (`id`)
) ENGINE=PBXT DEFAULT CHARSET=utf8;

Can anyone shed any light on why the field values change depending upon the conditions used in the following queries? It doesn't happen if the engine is Maria.

select * from outlet_tags where code=1503 and outlet_id=407 limit 3;
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| id   | importer_id | outlet_id | code | postcode | tag_set | tag_type        | tag_details    |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
|  222 |           1 |       407 | 1503 | XXX XXX  | outlet  | Make up         | Make up        |
|  675 |           1 |       407 | 1503 | XXX XXX  | outlet  | Approved Status | Approved       |
| 1619 |           1 |       407 | 1503 | XXX XXX  | outlet  | Retail Area     | No Retail Area |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
3 rows in set (0.00 sec)

select * from outlet_tags where code=1503 and importer_id=1 limit 3;
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| id   | importer_id | outlet_id | code | postcode | tag_set | tag_type        | tag_details    |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
|  222 |           1 |       407 | 1503 | XXX XXX  | outlet  | Make up         | Make up        |
|  675 |           1 |       407 | 1503 | XXX XXX  | outlet  | Approved Status | Approved       |
| 1619 |           1 |       407 | 1503 | XXX XXX  | outlet  | Retail Area     | No Retail Area |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
3 rows in set (0.00 sec)

select * from outlet_tags where importer_id=1 and outlet_id=407 limit 3;
+------+-------------+-----------+------+----------+---------+----------+-------------+
| id   | importer_id | outlet_id | code | postcode | tag_set | tag_type | tag_details |
+------+-------------+-----------+------+----------+---------+----------+-------------+
|  222 |           1 |       407 | 1503 | NULL     | NULL    | NULL     | NULL        |
|  675 |           1 |       407 | 1503 | NULL     | NULL    | NULL     | NULL        |
| 1619 |           1 |       407 | 1503 | NULL     | NULL    | NULL     | NULL        |
+------+-------------+-----------+------+----------+---------+----------+-------------+
3 rows in set (0.00 sec)

Update: as of MariaDB 5.5 PBXT was dropped as a storage engine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我是有多爱你 2024-10-07 11:03:53

尝试在查询中使用 ORDER BY。

不同的引擎可能以不同的顺序返回行,具体取决于行的检索方式。

Try using an ORDER BY with the queries.

Different engines may return rows in different order depending on how the rows are retrieved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文