简体   繁体   English

Mysql'where子句'用长表?

[英]Mysql 'where clause' with long tables?

I have designed a website like bit.ly, but a bit different. 我设计了一个像bit.ly这样的网站,但有点不同。 Written in php with mysql. 用mysql写的php。 When I was running it at localhost, everything seemed to work fine, pages loaded in 4.5 milliseconds, and I was as happy as a clam. 当我在localhost运行它时,一切似乎工作正常,页面加载时间为4.5毫秒,我就像蛤蜊一样快乐。

I uploaded it to the server, and users started surfing the website, and using it. 我将其上传到服务器,用户开始浏览网站并使用它。 Everything seemed to work fine untill the main table started reaching millions of rows. 一切似乎工作正常,直到主表开始达到数百万行。

The table is one million of rows length right now (it has to be that way), and growing. 该表现在是一百万行长度(必须是这样),并且正在增长。 The pages that needs that table take 500ms to load... The mysql query is the next: 需要该表的页面需要500ms才能加载... mysql查询是下一个:

select link
from table
where kind = $kind and kind_idd = $kind_idd and live = 1;

It can return more than 1 link, in fact, it usually returns between 10-50 links. 它可以返回多个链接,实际上它通常在10-50个链接之间返回。

The problem is that where clause. 问题是where子句。 I am sure that mysql should have something to make it faster. 我确信mysql应该有一些东西让它更快。 I have been asking google and I found indexes, keys, and so on. 我一直在问google,我找到了索引,密钥等等。 But I couldn't find a website that explained it for dummies.. If someone could give me an example to make this thing go fast, I would really appreciate it. 但我找不到一个网站,为傻瓜解释它..如果有人可以给我一个例子让这个东西快点,我会非常感激。

Thank you! 谢谢!

Try using the mysql explain plan so that you can see what is happening. 尝试使用mysql 解释计划,以便您可以看到发生了什么。

You probably need to ensure that you have indexes on kind, kind_idd and live see http://dev.mysql.com/doc/refman/5.0/en/create-index.html 您可能需要确保索引有kind, kind_idd and live请参阅http://dev.mysql.com/doc/refman/5.0/en/create-index.html

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

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