Deprecated: Function get_magic_quotes_gpc() is deprecated in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 6

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 16

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 127

Warning: Use of undefined constant newstempid - assumed 'newstempid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 130

Warning: Use of undefined constant temptext - assumed 'temptext' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 415

Warning: Use of undefined constant tempid - assumed 'tempid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 415

Warning: Use of undefined constant temptext - assumed 'temptext' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 415

Warning: Use of undefined constant temptext - assumed 'temptext' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 141

Warning: Use of undefined constant showdate - assumed 'showdate' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 142

Warning: Use of undefined constant title - assumed 'title' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 144

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 145

Warning: Use of undefined constant featherclass - assumed 'featherclass' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2175

Warning: Use of undefined constant featherclass - assumed 'featherclass' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2177

Warning: Use of undefined constant listdt - assumed 'listdt' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2187

Warning: Use of undefined constant classurl - assumed 'classurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2190

Warning: Use of undefined constant newsurl - assumed 'newsurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2191

Warning: Use of undefined constant classpath - assumed 'classpath' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2191

Warning: Use of undefined constant navfh - assumed 'navfh' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2200

Warning: Use of undefined constant classname - assumed 'classname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2200

Warning: Use of undefined constant listdt - assumed 'listdt' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2187

Warning: Use of undefined constant classurl - assumed 'classurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2190

Warning: Use of undefined constant newsurl - assumed 'newsurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2191

Warning: Use of undefined constant classpath - assumed 'classpath' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2191

Warning: Use of undefined constant navfh - assumed 'navfh' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2200

Warning: Use of undefined constant classname - assumed 'classname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2200

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 146

Warning: Use of undefined constant keyboard - assumed 'keyboard' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 146

Warning: Use of undefined constant checkdorepstr - assumed 'checkdorepstr' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/functions.php on line 368

Warning: Use of undefined constant newstext - assumed 'newstext' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 232

Warning: Use of undefined constant newsurl - assumed 'newsurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 302

Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 324

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 325

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 326

Warning: Use of undefined constant classname - assumed 'classname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 326

Warning: Use of undefined constant ttid - assumed 'ttid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 327

Warning: Use of undefined constant ttid - assumed 'ttid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 328

Warning: Use of undefined constant tname - assumed 'tname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 328

Warning: Use of undefined constant onclick - assumed 'onclick' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 330

Warning: Use of undefined constant userfen - assumed 'userfen' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 331

Warning: Use of undefined constant username - assumed 'username' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 332

Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 334

Warning: Use of undefined constant username - assumed 'username' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 340

Warning: Use of undefined constant userid - assumed 'userid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 342

Warning: Use of undefined constant newsurl - assumed 'newsurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 344

Warning: Use of undefined constant plnum - assumed 'plnum' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 345

Warning: Use of undefined constant totaldown - assumed 'totaldown' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 346

Warning: Use of undefined constant keyboard - assumed 'keyboard' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/action/ShowInfo.php on line 347

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2418

Warning: Use of undefined constant wburl - assumed 'wburl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2418

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2423

Warning: Use of undefined constant listdt - assumed 'listdt' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2423

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2428

Warning: Use of undefined constant classurl - assumed 'classurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2428

Warning: Use of undefined constant newsurl - assumed 'newsurl' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2434

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2434

Warning: Use of undefined constant classpath - assumed 'classpath' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2434

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2436

Warning: Use of undefined constant bname - assumed 'bname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2436

Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2439

Warning: Use of undefined constant bname - assumed 'bname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/class/connect.php on line 2439
面试官:为什么 MySQL 不推荐使用 join? - <br /> <b>Warning</b>: Use of undefined constant sitename - assumed 'sitename' (this will throw an Error in a future version of PHP) in <b>/www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php</b> on line <b>13</b><br /> 天浩工作室
最新公告
  • 欢迎您光临天浩工作室,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入钻石VIP

  • Warning: Use of undefined constant money - assumed 'money' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 209

    Warning: Use of undefined constant vipzk - assumed 'vipzk' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 210

    Warning: Use of undefined constant vipzk - assumed 'vipzk' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 214

    Warning: Use of undefined constant vipzk - assumed 'vipzk' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 215

    Warning: Use of undefined constant vipzk - assumed 'vipzk' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 216

    Warning: Use of undefined constant money - assumed 'money' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 216

    Warning: Use of undefined constant yongjiuzk - assumed 'yongjiuzk' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 218

    Warning: Use of undefined constant yongjiu - assumed 'yongjiu' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 221

    Warning: Use of undefined constant spsf - assumed 'spsf' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 227

    Warning: Use of undefined constant viptext - assumed 'viptext' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 227

    Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 270

    Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 270

    Warning: Use of undefined constant video - assumed 'video' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 271

    面试官:为什么 MySQL 不推荐使用 join?

    正文概述
    Warning: Use of undefined constant writer - assumed 'writer' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 322
    天浩工作室  
    Warning: Use of undefined constant newstime - assumed 'newstime' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 322
    2023-12-01
       633

    往往开发的实际问题和面试理论中的八股文并不一致。

    导致明明有很多年的开发经验,但是一遇到面试就凉凉,就比如这道题。

    对于MySQL而言,不推荐使用子查询和JOIN语句,因为JOIN的效率较低。

    1. 当数据量很大时,很难保证效率。强烈建议先从单表中获取数据,然后在程序中进行JOIN和合并数据。

    2. 子查询的效率更低,执行子查询时,MySQL需要创建临时表,并在查询结束后删除这些临时表,因此子查询的速度会受到影响。

    3. 如果使用JOIN,它将使用嵌套查询。小表驱动大表,并通过索引字段进行关联。如果表中的记录较少,这样做是可以的。但对于大表来说,可以在业务逻辑中进行控制处理。

    4. 数据库通常是瓶颈,建议将数据库仅作为数据存储工具,而不要将业务逻辑添加到其中。

    先来说说JOIN查询的好处:

    是的,在数据规模没有达到上百万级别的情况下,join查询尤其一定的作用。

    1. 数据关联:

      join查询可以将多个表中的数据关联起来,使得我们可以根据共同的列值获取相关联的数据。这样可以方便地获取需要的信息,而不需要手动进行多次查询和数据处理。

       

    2. 数据一致性

      通过join查询,我们可以确保关联的数据是一致的。例如,如果我们需要获取订单表和客户表中的信息,通过join查询可以确保只返回订单表中存在对应客户的订单,避免了数据不一致的情况。

       

    3. 查询效率:

      在某些情况下,使用join查询可以提高查询效率。通过将多个表连接起来,可以减少查询的次数,避免了多次查询和数据传输的开销。此外,数据库系统可以通过优化join查询的执行计划来提高查询效率。

       

    4. 代码简洁性:

      使用join查询可以简化代码逻辑。相比于手动进行多次查询和数据处理,使用join查询可以将多个查询合并为一次查询,减少了代码的复杂性和冗余。

       

    需要注意的是,join查询也有一些限制和注意事项。

    例如,如果关联的表数据量很大,可能会导致查询性能下降。

    不推荐使用JOIN的原因包括:

    1. 数据库承担的业务压力较大,应尽量减少负担。当表的记录数达到百万级别时,JOIN会导致性能下降。

    2. 在分布式的分库分表环境中,不建议进行跨库JOIN。目前MySQL的分布式中间件对跨库JOIN的支持不好。

    3. 修改表的结构时,单表查询的修改相对容易,而JOIN语句的修改较为困难,成本较高。当系统较大时,难以维护。

    不使用JOIN的解决方法:

    1. 是在业务层,先查询单个表的数据,然后将其作为条件给下一个单表查询。

    但需要注意查询的结果集可能会很大。MySQL没有对IN()的数量进行限制,但限制了整条SQL语句的大小。

    可以通过调整参数max_allowed_packet来修改一条SQL的最大值。建议在业务上进行合理处理,限制一次查询的结果集大小是可接受的。

    2. 此外,合适的索引设计和查询条件的优化也是保证join查询效率的重要因素。

    综上所述,join查询在关系型数据库中具有数据关联、数据一致性、查询效率和代码简洁性等好处。但在实际应用中,需要根据具体情况进行合理的使用和优化。


    Warning: Use of undefined constant viptext - assumed 'viptext' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 333


    Warning: Use of undefined constant sitename - assumed 'sitename' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 352
    天浩工作室
    » 面试官:为什么 MySQL 不推荐使用 join?

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    模板不会安装或需要功能定制以及二次开发?
    请QQ联系我们

    发表评论

    还没有评论,快来抢沙发吧!

    如需帝国cms功能定制以及二次开发请联系我们

    联系作者

    Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 917

    Warning: Use of undefined constant classid - assumed 'classid' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 917

    Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 917

    请选择支付方式

    ×

    Warning: Use of undefined constant payname - assumed 'payname' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.tianhao.cc/e/data/tmp/dt_temptext1.php on line 931
    微信支付
    余额支付
    ×
    微信扫码支付 0 元