• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » MySQL Persistent Connection to Optimize WordPress

By Abhishek Ghosh February 29, 2012 11:38 pm Updated on December 26, 2021

MySQL Persistent Connection to Optimize WordPress

Advertisement

MySQL Persistent Connection can be used to Optimize WordPress Page Loading Speed. It depends on server configuration, otherwise performance will degrade. By default, MySQL Persistent Connection is not enabled in WordPress. We can, however force WordPress to use MySQL Persistent Connection. Here is how to force WordPress to use MySQL Persistent Connection, what should be the monitoring tools and on what Server Configuration MySQL Persistent Connection probably work better.

 

What is MySQL Persistent Connection

 

When we are using non persistent connection, every time WordPress MySQL queries are opening and closing the database connection. This function to some extent remains even when we use a Cache Plugin. Because there are some PHP calls which are not Cached. Sometimes we force with HTML comments to make it work as live, non cached. But in case of forced  MySQL Persistent Connection usage, when connecting to the database, the call / function will try to find an already opened with the same username and password. So, if one connection is already made before, it will not require to check the username and password. So logically using  MySQL Persistent Connection can at least work better for backend of the WordPress, not if frontend.

 

How to force  MySQL Persistent Connection in WordPress

 

Basically editing one file in wp-includes folder. That file is wp-db.php ; there are three lines (in WordPress 3.3.1) where mysql_connect() has been used. If we replace these with mysql_pconnect() then we are basically forcing MySQL Persistent Connection. Actually editing only @mysql_connect will serve the purpose. MySQL is a very big ocean and I have very little knowledge about MySQL, I think it is better to change all the three mysql_connect to mysql_pconnect to force MySQL Persistent Connection.

Advertisement

---

 

For whom MySQL Persistent Connection will work better

 

Just like we are using a server platform with virtually no limit of physical RAM and our PHP memory can be increased for WordPress to any digit. If there is very less PHP memory then forcing MySQL Persistent Connection will return 500 server error. You will get these in your PHP error log.

 

Tools to check health and performance after forcing MySQL Persistent Connection

 

First tool to check the efficiency of MySQL Persistent Connection is webpagetest.org – to check the Page Loading Speed after forcing MySQL Persistent Connection. Second is your PHP error log to check errors after using MySQL Persistent Connection.

 

Our test and result with MySQL Persistent Connection

 

We have tested this MySQL Persistent Connection on 5 WordPress installation with medium to quite high traffic. We have noted almost no difference in page loading speed after forcing MySQL Persistent Connection. To show you the performance after forcing MySQL Persistent Connection, here are two screenshots (like those hair growing lotion adverts!) :

 

Here is the performance before forcing MySQL Persistent Connection :

 

MySQL Persistent Connection
Here is the performance after forcing MySQL Persistent Connection :

after MySQL Persistent Connection to Optimize WordPress

Inference on MySQL Persistent Connection for WordPress

 

You can check our one of other site Daily Medico ; we kept the forced MySQL Persistent Connection on for this one. Its loading very fast on ‘feel’ – within 1.3 seconds but the problem is there are PHP errors are also getting generated. So the crux is probably forcing MySQL Persistent Connection even on high end cloud server with loadbalancers is not very safe although it might increase the page loading speed a bit, at least the ‘feel’ becomes ‘its loading faster’.

 

SignatureTagged With wordpress persistent database connection , wordpress mysql optimization , wordpress optimization speed , wordpress database connection limit , PHP MySQL Allow Persistent Connections: On , Persistent Connection wordpress , persistent connection updater wordpress , persist connection to database on wordpress , optimize wordpress website speed , optimize mysql server for wordpress
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to MySQL Persistent Connection to Optimize WordPress

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy