dpbtbcz6650 2014-02-10 10:46
浏览 26

mysql采用不同的执行时间

SELECT user.name, user.age, user.lastlogin, user.loguserid,user.sex, ( 3963.17 * ACOS( COS( RADIANS( 54.662280100000) ) * COS( RADIANS( latitude ) ) * COS( RADIANS( -1.630407900000) - RADIANS( longitude ) ) + SIN( RADIANS( 54.662280100000 ) ) * SIN( RADIANS( latitude ) ) ) ) AS distance_in_miles
FROM user
WHERE latitude != '' 
AND longitude != ''
AND loguserid !=526306 
AND age >18 AND age <=50 
AND  sex !=0
AND ( 3963.17 * ACOS( COS( RADIANS( 54.662280100000 ) ) * COS( RADIANS( latitude ) ) * COS( RADIANS( -1.630407900000 ) - RADIANS( longitude ) ) + SIN( RADIANS( 54.662280100000) ) * SIN( RADIANS( latitude ) ) ) ) <=50 
AND NOT EXISTS (SELECT blockuser.userid
FROM blockuser 
WHERE blockuser.newuserid = user.loguserid 
AND blockuser.userid =526306 AND siteid =1071) 
AND NOT EXISTS (SELECT fav.userid FROM fav WHERE fav.favuserid =user.loguserid
AND siteid =1071 AND fav.userid =526306 ) ORDER BY `user`.`loguserid` DESC

Here is my sql?it always show different time of execution?any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • duanjihe5180 2014-02-10 10:57
    关注

    MySql has a query cache. If the same statement is executed a second time, usually this takes only part of the time compared to the first execution, since the result can e taken from the query cache.

    Once the cache has been invalidated / purged, it will again need a bit more time to execute.

    Depending on what other clients on the database are doing, probably this statement waits for a release of a table lock which is needed for the sub-queries etc. There are precedences in the locks for SELECT, INSERT and UPDATE which probably apply.

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算