donglong7338 2013-06-22 15:48
浏览 16
已采纳

使用mysqli_change_user,还是不使用?

I am setting up a database class in my php application, and I was planning on using either PDO or MySQLi. I was thinking of persistant connections, but I am wondering if this is the best idea. I saw, unlike PDO, MySQLi automaticly resets the state of the connection with mysqli_change_user().

However, as noted in the PHP manual, it states that the mysqli_change_user() function is expensive and could degrade performance, but that you can also disable it.

I currently have two questions:

  • Are persistant connections a good idea? And if so, with PDO or MySQLi?
  • Is the mysqli_change_user() function so expensive that it nullifies the performance increase of using a persistant connection? If so, is it such a bad idea to disable it, if you have written proper code?
  • 写回答

2条回答 默认 最新

  • dongyikong6207 2013-06-22 16:14
    关注

    Are persistant connections a good idea?

    Yes, in general. Save for the cheap shared hostings where you shouldn't use it.

    And if so, with PDO or MySQLi?

    If you want to change user - mysqli is the only choice. If not - it's irrelevant.

    Is the mysqli_change_user() function so expensive that it nullifies the performance increase of using a persistant connection?

    My common sense is telling me that it is not.

    If so, is it such a bad idea to disable it, if you have written proper code?

    Personally, I wouldn't bother at all.

    There is a one problem with performance issues. Some of them are real ones but some just imaginary, taken out of nowhere. A strange thing - these latter makes huge impression to developers. It always makes me wonder, how much time and efforts being spend to solve a problem which noone ever noticed or measured on a live application.

    What I would suggest is to profile your existing application (if any), and I bet 100:1 that you will find several places in your code which do 1000 times stronger impact on performance than this imaginary expense.

    So, I would keep it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料