简体   繁体   English

要在哪一列上建立索引并使表搜索快速

[英]What column to index on and making table search fast

I have a table that holds stats for a game, this table will have hundreds of thousands of lines in but i need to it be searchable for the stats pages of the game. 我有一个表,其中包含游戏的统计信息,该表中有成千上万的行,但是我需要可以在其中搜索游戏的统计信息页面。

I am not sure what I need to do regarding indexing and how to keep the table searchable in a realistic time. 我不确定在建立索引方面需要做些什么以及如何在现实的时间内使表可搜索。 I normally index the Id field which is a primary key. 我通常索引作为主键的ID字段。 I don't really understand indexing so am not sure if I am doing the correct thing. 我不太了解索引编制,因此不确定我是否在做正确的事情。

Can anyone lend some advice please? 任何人都可以提出一些建议吗? I am using a MySQL database. 我正在使用MySQL数据库。

Thanks. 谢谢。

Rule of thumb - index columns that you are using in the WHERE clause and those being used in the ORDER BY . WHERE子句中使用的经验索引索引列以及在ORDER BY中使用的经验索引索引列。

You should always, however, test the effects of the change - sometimes adding indexes can cause performance problems. 但是,您应该始终测试更改的效果-有时添加索引可能会导致性能问题。

I suggest reading one of the many tutorials on optimizing mysql and following the advice with your table. 我建议阅读许多有关优化mysql的教程之一,并按照表中的建议进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM