【发布时间】:2009-10-20 21:11:34
【问题描述】:
我有一个结构如下的表:
id bigNumber text
1 1200321030011010233 "an item with some text"
2 1200321030011014563 "another item with some more text"
3 3120323434432211133 "more...."
.
.
.
该表包含大约 50,000 条记录。我想做以下查询,但速度很慢:
SELECT COUNT(*),
bigNumber
FROM items
GROUP BY substr(bigNumber, 1, X)
其中 X 在 2 和 19 之间变化。
创建 19 列并在每列中包含部分数字以便能够使用索引会更快吗?
【问题讨论】:
标签: mysql sql group-by substring