duanqi6007 2013-10-24 17:23
浏览 27
已采纳

使用通配符和缩小的mysql查询来拉取详细信息[重复]

This question already has an answer here:

I'm playing around with a PHP/MySQL. I can't devise what is "better" and why ?

This isn't really a direct technical question but more of a efficiency related question.

I'm trying to pull 1 row from a table, this is the general code:

$query=mysqli_query($con,"SELECT * FROM `tracked_sites` WHERE checkType =1");
while ($row = mysqli_fetch_assoc($query)) {
    echo $row["domain"] . "<br/>";
}

This works and everything is just fine, however I could also do it using a more specific query, instead of using wildcard. I could just specify the domain and it would trim down the results to just that row.

I'm trying to understand what would be the impact (if any) on larger dbs (lets say 10M or 100M items)?

</div>
  • 写回答

1条回答 默认 最新

  • drutjkpsr67393592 2013-10-24 22:20
    关注

    Reducing the width of the data fetched the database will always improve performance - the DBMS must allocate memory for any data it reads from the disk, it must then transmit that to the client and the client must allocate memory to store it. The more memory is used, he slower a system gets.

    However if the difference is only a few kb, then this on its own won't have much impact - but what does have a very big performance impact is when you select data using a covering index.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题