MariaDB、PBXT 和神秘的查询结果
首先,这是表格:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在查询中使用 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.