开发者

MySQL: crazy slow performance using ORDER BY

I have a very long query (i dont need to show it now) that searches for items (apartments) in a very small db of 500 total houses and calculate proximity given the lon/lat of each and i thought it was slow because of that calculation, but after playing a little i noticed that removing completly the ORDER BY, the time decreased form 7.6 seconds to 0.08!!

how coudld it be that the ORDER by creates this huge gap of time??...

UPDATE: i played other five minutes and开发者_运维技巧 read other bunch of forums and they warn about the JOIN thing...well i removed a RIGHT JOIN statement... well it is fast again!!


Well, your database might have poorly defined fields. For instance, if you have a table that has no Primary Key defined, it will take longer to search and sort. Don't use not in. It is terribly inefficient. The issue is hard to define the problem without seeing a table structure or the query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜