Only just started using Piwik (1.1.1) a few weeks ago and love it!
One annoying thing we’ve noticed is that when a user initially accesses a site page there is a delay of 5-10 seconds for that first Piwik access (verified that removing the Javascript code from the page eliminates the delay). Haven’t found anything related in the documentation or FAQ.
The working assumption is that this is related to the initial DB connection (using MySQL (4.1.12a-nt) on a Windows Server 2008).
Piwik is running on the same server so the embedded Piwik script code defines pkBaseURL by a relative URL as ‘…/piwik/’
(a fully qualified URL has the same delay problem)
We’ve also modified the hosts file to include the server/IP name
both hoping to minimize any DNS associated delays in the DB connection.
Looking for other configuration / optimization suggestions to minimize or eliminate that initial delay.
the things you say sound quite unusual to me. I am no Win server expert but having a 5+ second delay while opening a socket to your DB looks to me as if your server suffers from serious performance issues. My first bet is to not look at Piwik but at MySQL. A good starting point, given that your databases reside on performant storage and you have enough free RAM, might be MySQL :: MySQL 5.7 Reference Manual.
Also, take a look at the included example confiurations, i might be wrong but i think i once saw a Windows-optimized MySQL.conf around there.