donglei2288 2014-10-28 10:40
浏览 76

一个mysql查询的执行时间,在php中比phpmyadmin慢。 我怎么能克服这一点

I was running a query in phpmyadmin, it takes around 0.0012 sec to execute.

 Showing rows 0 - 29 ( 727,934 total, Query took 0.0012 sec)

may be because of by default limitation in phpmyadmin. But it count the total no of row.

But in php, I need the total no of row .I was running the query without limitation that takes around 6-8 second of time to execute the query.

is their any way to solve this issue.

  • 写回答

1条回答 默认 最新

  • dongxingdu9594 2016-04-06 14:08
    关注

    I have had a similar problem and in my case it was due to the fact that I was not using the correct data types. So while I wanted to query my VarChar Type Index Field with a VarChar I mistakenly formulated the query in such a way that I queried it with and Int Paramter. This resulted in the index not being utilized but rather a full table scan being performed. By example I did:

    SELECT * FROM table WHERE Indexfield = 015523;
    

    when I should have done the following:

    SELECT * FROM table WHERE Indexfield = '015523';
    

    There is some more insight into the issue here: https://www.percona.com/blog/2006/09/08/why-index-could-refuse-to-work/

    评论

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接