php vs mysql速度 [英] php vs mysql speed

查看:59
本文介绍了php vs mysql速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

让mySql在一个

复杂查询中查找尽可能多的数据或让php完成所有复杂的处理并提交是否更快

很多关于mysql数据库的简单查询?


干杯,
$ b $bCiarán

Hi All,
Is it faster to have mySql look up as much data as possible in one
complex query or to have php do all the complex processing and submit
lots of simple queries to the mysql database?

Cheers,
Ciarán

推荐答案

5月10日下午5:05,David Gillen< Bel ... @ RedBrick.DCU.IEwrote:
On May 10, 5:05 pm, David Gillen <Bel...@RedBrick.DCU.IEwrote:

Ciaran说:大家好,
Ciaran said:Hi All,

让mySql在一个中查找尽可能多的数据是否更快

复杂的查询还是要让php做所有复杂的处理并提交给bql的mb数据库提交很多简单的查询?
Is it faster to have mySql look up as much data as possible in one
complex query or to have php do all the complex processing and submit
lots of simple queries to the mysql database?



它有所不同。有时候,带有嵌套子查询的复杂多连接查询可能会更快,有时会花费更长时间。

很多时候将取决于数据库的设置方式规范化和

表格上的索引等。

如果没有对这两种情况进行独立测试,则无法知道


< br $>
D.

-

费马是对的。


It was vary. Sometime a complex multijoin query with nested sub-queries may be
quicker, other times it will take far longer.
Alot will depend on how your database is setup in terms of normalisation and
indexes on tables etc.
Without doing independent tests yourself for both cases it is impossible to
know.

D.
--
Fermat was right.



嗯,在最基本的水平怎么样。例如,运行更快是


SELECT * FROM users WHERE userID IN

(1,2,4,7,8 ,9,10,11,13,14,15,17,18,35等等);


或者在PHP foreach循环中单独选择每个userID

喜欢这样的声明:

SELECT * FROM users WHERE userID = 2 LIMIT 1;


我基本上是在问:它是否正在联系数据库,这会降低PHP的运行速度,或者它是mySQL运行的实际速度。


前者表明一个大的查询通常是更快

而后者表明许多基本查询通常会更快。

我只是在这里寻找经验法则,答案不是很好。


干杯,
$ b $bCiarán


Hmm, What about at the most basic level. For example would it be
quicker to run:
SELECT * FROM users WHERE userID IN
(1,2,4,7,8,9,10,11,13,14,15,17,18,35,etc,etc,etc);

or select each userID seperately in a PHP foreach loop with something
like this statement:
SELECT * FROM users WHERE userID=2 LIMIT 1;

I''m basically asking: Is it contacting the database that slows down
PHP or is it the actual speed at which mySQL runs.

The former suggests that one big query would generally be quicker
while the latter suggests many basic queries would generally be
quicker.
I''m just looking for a rule of thumb here, not hard answers.

Cheers,
Ciarán




Ciaran写道:

Ciaran wrote:

让mySql在一个
复杂查询中查找尽可能多的数据是否更快让php完成所有复杂的处理并向mysql数据库提交大量简单查询吗?
Is it faster to have mySql look up as much data as possible in one
complex query or to have php do all the complex processing and submit
lots of simple queries to the mysql database?



我猜想一个好的DBMS可以比你更快地完成它。我不知道很多关于MySQL的问题,但是有了一个不错的优化器和一些索引,DBMS

通常会更快。至少如果它不是一个完全奇怪的查询:)


也许你可以定义完全查询 (在这里发布查询?),并定义

你的意思是很多简单的查询。

I''d guess that a good DBMS can do it faster than you. I do not know that
much about MySQL, but with a decent optimizer and some indexes, the DBMS
will usually be faster. At least if it is not a completely strange query :)

Maybe you could define "compley query" (post the query here?), and define
what you mean with "lots of simple queries".


Ciaran写道:
Ciaran wrote:

嗯,在最基本的水平怎么样。例如,运行更快是


SELECT * FROM users WHERE userID IN

(1,2,4,7,8 ,9,10,11,13,14,15,17,18,35等等);


或者在PHP foreach循环中单独选择每个userID

喜欢这样的声明:

SELECT * FROM users WHERE userID = 2 LIMIT 1;
Hmm, What about at the most basic level. For example would it be
quicker to run:
SELECT * FROM users WHERE userID IN
(1,2,4,7,8,9,10,11,13,14,15,17,18,35,etc,etc,etc);

or select each userID seperately in a PHP foreach loop with something
like this statement:
SELECT * FROM users WHERE userID=2 LIMIT 1;



就复杂性而言,两个查询都同样复杂,尽管

第一个看起来有点像设计问题。无论如何,这样做第一种方式将比第二种方式快得多(在我的

意见中)

In terms of complexity, both queries are equally complex, although the
first one looks a bit like there is some design issue. Anyways, doing it
the first way will be lot faster than doing it the second way (in my
opinion)


我基本上是在问:它是否正在联系数据库,这会减慢PHP的价格,或者它是mySQL运行的实际速度。
I''m basically asking: Is it contacting the database that slows down
PHP or is it the actual speed at which mySQL runs.



取决于:

Depends :)


前者暗示一个大查询通常会更快

而后者表明许多基本查询通常会更快。

我只是在寻找一个经验法则,而不是硬答案。
The former suggests that one big query would generally be quicker
while the latter suggests many basic queries would generally be
quicker.
I''m just looking for a rule of thumb here, not hard answers.



请参阅我的其他帖子。

See my other post.


这篇关于php vs mysql速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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