1
我想使用一個內存表作爲一組隊列。內存表的主鍵必須是HASH,爲什麼?
所以,就會有與INT列A和B的存儲器表。
與像查詢:
SELECT B,從表,其中A =? ORDER經B DESC LIMIT 1000
我嘗試這樣做:
create table `test_table` (
`a` int(11) not null,
`b` int(11) not null,
primary key (`a`,`b`) using btree
) engine=memory
但主鍵仍然是HASH:
show index from `test_table`
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
---------- ---------- -------- ------------ ----------- --------- ----------- -------- ------ ------ ---------- -------
test_table 0 PRIMARY 1 a (NULL) (NULL) (NULL) (NULL) HASH
test_table 0 PRIMARY 2 b (NULL) 0 (NULL) (NULL) HASH
難道這意味着,我需要創建另一個鍵(
a
)這樣的查詢?爲什麼主鍵不能是B樹索引?如果我將主鍵更改爲常規鍵,有什麼區別?