我是否低估了 MySQL? [英] Am I underestimating MySQL?

查看:43
本文介绍了我是否低估了 MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将在我的网站上实施一项功能,该功能根据用户库中已有的内容(la Last.fm)向用户推荐内容.单个表包含他们添加的内容的所有记录,因此一行可能看起来像:

I'm about to implement a feature on my website that recommends content to users based on the content they already have in their library (a la Last.fm). A single table holds all the records of the content they have added, so a row might look something like:

--------------------
| userid | content |
--------------------
|   28   |    a    |
--------------------

当我想为用户推荐一些内容时,我使用查询来获取所有在其库中添加了内容的用户 ID.然后,从这些用户 ID 中,我进行另一个查询,在这些用户中找到下一个最常见的内容(fx.'b'),并将其显示给用户.

When I want to recommend some content for a user, I use a query to get all the user id's that have content a added in their library. Then, out of those user id's, I make another query that finds the next most common content among those users (fx. 'b'), and show that to the user.

我的问题是当我考虑这里的大局时.假设最终我的站点将在表中保存 500.000 行,这会导致 MySQL 响应非常缓慢还是我在这里低估了 MySQL?

My problem is when I'm thinking about the big picture here. Say that eventually my site will hold something like 500.000 rows in the table, will this make the MySQL response very slow or am I underestimating MySQL here?

推荐答案

在测试之前你不会知道这一点,所以开始原型设计.

You will not know this until you've tested it, so start prototyping.

通常,500 000 行几乎为零.当我的表达到 5000 万时,我有点担心,因为当我必须清除旧数据时需要一段时间 - 尽管查询数据仍然很快.

Typically, 500 000 rows is next to nothing. I worry a bit when my tables reach 50 millions, cause then it takes a while when I have to purge old data - though querying data is still fast.

但这一切都取决于您需要的查询类型.跨越所有这 5000 万行的查询确实会非常慢,只有涉及这 5000 万行中的 50k 的查询很快.对于您的问题,您需要衡量您的查询,调整您的查询、表/索引和 mysql 本身.

But this all depends on the kinds of queries you need. Queries spanning all those 50 million rows would indeed be very slow, queries only touching 50k of those 50 millions are fast. And for your problem, you need to measure your queries, tune your queries, tables/indexes and mysql itself.

这篇关于我是否低估了 MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆