<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Horde pings SQL server with each database query</title> 
  <pubDate>Fri, 10 Apr 2026 01:27:08 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/12656</link> 
  <atom:link rel="self" type="application/rss+xml" title="Horde pings SQL server with each database query" href="https://bugs.horde.org/ticket/12656/rss" /> 
  <description>Horde pings SQL server with each database query</description> 
 
   
   
  <item> 
   <title>While monitoring my MySQL server stats, I noticed that half </title> 
   <description>While monitoring my MySQL server stats, I noticed that half of the queries performed are &#039;SELECT 1&#039; (ping) requests. While it may be a good idea to ping the SQL server if we haven&#039;t heard from it for a while, sending 150 pings in quick succession every $conf[activesync][ping][waitinterval] for each ActiveSync connection is may be a overkill.

Not that I&#039;m worried about the SQL server load (the load for a &#039;SELECT 1&#039; is probably negliable compared to the &#039;real&#039; queries doing the actual work), but sending a ping for each SQL query effectively doubles the round trip delay to the server. While this may not be much of an issue if the webserver and database are on the same (physical) machine, it may add up if they are not.

Idealy, a timestamp should be stored with the connection so that a ping is only sent if the last time we heard from the server on this connection was more than &#039;X&#039; seconds ago (with X probably a hardcoded value of maybe 10 to 30 seconds). I can see if I can come up with a patch to do this, but my PHP skills are mediocre at best, so please bear with me.</description> 
   <pubDate>Wed, 04 Sep 2013 07:17:28 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t80546</link> 
  </item> 
   
  <item> 
   <title>Not surprisingly, I&#039;m not the first to note such behaviour:</title> 
   <description>Not surprisingly, I&#039;m not the first to note such behaviour:

http://www.mysqlperformanceblog.com/2010/05/05/checking-for-a-live-database-connection-considered-harmful/

For what it&#039;s worth...</description> 
   <pubDate>Wed, 04 Sep 2013 10:53:07 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t80551</link> 
  </item> 
   
  <item> 
   <title>My first shot at trying to reduce the number of pings to the</title> 
   <description>My first shot at trying to reduce the number of pings to the SQL database.

Assume the connection to the database is good (which will generally be the case) and send queries straight away. Only ping the SQL database if an exception occurs (much less common). If the server doesn&#039;t respond, reconnect and try again (up to three times). If does respond to the ping, assume something else was wrong and throw exception as usual.

The logic might be improved by interpreting $e-&gt;getMessage(). If it contains &#039;SQLSTATE[08&#039;, there is a definitly a connection problem and we should reconnect. But I&#039;m not sure if all supported SQL databases support this status code, hence the (slightly less efficient) ping.</description> 
   <pubDate>Wed, 04 Sep 2013 17:40:39 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t80568</link> 
  </item> 
   
  <item> 
   <title>By the way, the subject should really be &quot;Horde pings MySQL </title> 
   <description>By the way, the subject should really be &quot;Horde pings MySQL server with each database query&quot;, since this happens only for the &#039;MySQL / PDO&#039; and &#039;MySQL (mysqli)&#039; backends. I&#039;m not sure if something similar happens with the &#039;PostgreSQL&#039; and &#039;SQLite&#039; backends.

Attached a slightly modified patch, which doesn&#039;t ping the server the last time if the number of retries is exceeded already and an exception will be thrown anyway.</description> 
   <pubDate>Thu, 05 Sep 2013 10:58:19 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t80571</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in Git (master):

commit 6473f788bd06</title> 
   <description>Changes have been made in Git (master):

commit 6473f788bd06787aecea9fbce3cde8ea6f3491ea
Author: Jan Schneider &lt;jan@horde.org&gt;
Date:   Tue Sep 10 14:50:52 2013 +0200

    [jan] Don&#039;t ping server before each query in PDO drivers (Bug #12656).

 framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php |    2 --
 framework/Db/package.xml                       |    2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

http://git.horde.org/horde-git/-/commit/6473f788bd06787aecea9fbce3cde8ea6f3491ea</description> 
   <pubDate>Tue, 10 Sep 2013 12:51:09 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t80618</link> 
  </item> 
   
  <item> 
   <title>I actually simply removed the ping, we don&#039;t ping in other b</title> 
   <description>I actually simply removed the ping, we don&#039;t ping in other backends than PDO either. Retrying on connection issues is a nice touch, and we may want to add this at some point. But this needs to be done across all backends then.</description> 
   <pubDate>Tue, 10 Sep 2013 12:55:51 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t80620</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in Git (master):

commit 0100bfdd7cff</title> 
   <description>Changes have been made in Git (master):

commit 0100bfdd7cff2a994be76fd0831c3aafb567e2c7
Author: Jan Schneider &lt;jan@horde.org&gt;
Date:   Tue Sep 10 14:50:52 2013 +0200

    [jan] Don&#039;t ping server before each query in PDO drivers (Bug #12656).

 framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php |    2 --
 framework/Db/package.xml                       |    2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

http://git.horde.org/horde-git/-/commit/0100bfdd7cff2a994be76fd0831c3aafb567e2c7</description> 
   <pubDate>Tue, 17 Dec 2013 11:36:24 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/12656#t81844</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
