PDO在mysql中的性能 [英] PDO in mysql performance

查看:75
本文介绍了PDO在mysql中的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我正在浏览一个博客,并注意到有关在mysql中使用PDO的一些观点,这改变了我对PDO的看法. 这些要点是:

Recently I was going through a blog and noticed some points about using PDO in mysql and it changed my view about the PDO. The points are :

  1. 本机准备好的语句无法利用查询缓存,从而导致性能降低.

  1. Native prepared statements cannot take advantage of the query cache, resulting in lower performance.

本机准备好的语句无法执行某些类型的查询,例如"SHOW TABLES"

Native prepared statements cannot execute certains types of queries, like "SHOW TABLES"

本机准备好的语句不能正确传达某些其他"SHOW"查询的列长,从而导致结果乱码.

Native prepared statements don't correctly communicate column lengths for certain other "SHOW" queries, resulting in garbled results.

使用本地准备好的语句多次调用存储过程会导致连接断开.

Calling stored procedures multiple times using native prepared statements causes the connection to drop.

任何人都可以对此发表评论吗?

Can anyone comment on this please?

我想在我的Web应用程序中查询缓存.考虑到我网站的性能问题后,我准备移动我的Web应用程序以使用PDO. 有人可以建议我吗?

I wanted query cache in my web app. I am preparing to move my web app to make use of PDO after considering performance issues with my website. Can anyone please suggest me?

谢谢.

推荐答案

好吧

  • 您是第一个观点的人
  • SHOW和SHOW TABLES是大多数情况下不常用的命令
  • 我将准备好的语句与存储过程结合使用,但尚未遇到此类问题.

您可以使用以下命令来启用查询缓存:

You may use the following command to enable query caching:

$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

此命令仅在PHP 5.1.3中可用.

This command is available from PHP 5.1.3 on only.

这篇关于PDO在mysql中的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆