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 关于大棚监测的pcb板设计
  • ¥20 sim800c模块 at指令及平台
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计