dsfw2154 2016-03-09 09:08
浏览 8
已采纳

最快的方式连接MySQLi? [关闭]

I just wondered what the fastest way to connect to MySQLi is? I have yet to find a stackoverflow post on this, if there is even a fastest way or if every way is faster, I really want to milk the speed for all it is with my application.

  • 写回答

2条回答 默认 最新

  • doukang7501 2016-03-09 14:28
    关注

    You don't need a HandlerSocket.

    • HandlerSocket is a MySQL plugin that implements a NoSQL protocol for MySQL.
    • Allows applications to communicate more directly with MySQL storage engines, without the overhead associated with using SQL.

    From the docs:

    Once HandlerSocket has been downloaded and installed on your system, there are two steps required to enable it.

    First, add the following lines to the [mysqld] section of your my.cnf file:

    loose_handlersocket_port = 9998
      # the port number to bind to for read requests
    loose_handlersocket_port_wr = 9999
      # the port number to bind to for write requests
    loose_handlersocket_threads = 16
      # the number of worker threads for read requests
    loose_handlersocket_threads_wr = 1
      # the number of worker threads for write requests
    open_files_limit = 65535
      # to allow handlersocket to accept many concurrent
      # connections, make open_files_limit as large as
      # possible.
    

    Second, log in to mysql as root, and execute the following query:

    mysql> install plugin handlersocket soname 'handlersocket.so';
    

    I agree @Your Common Sense that using a HandlerSocket is NOT even needed. Unless your a major corporation and every second counts.


    The fastest, normal way to connect

    $db = mysqli_connect("localhost","my_user","my_password","my_db");
    $db->query("...");
    

    How much speed do you actually need? If you need corporate size speed, I can help you with HandlerSocket. My guess is that you'll be just fine with standard MYSQLi connection.

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

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改