473,383 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Sleepy database

Hi group,

I have a site, which content is mostly based on what it finds in a
mySQL database.
All queries etc. are performed by PHP. Somehow, no matter what section
of the
site (still in test fase) i access, either small, with little DB info,
or bif with big DB info,
it seems that when i haven't accessed the page in at least 5 minutes,
access it again
the database is a lot slower the first load.
As if it has to wake up, and get started again. When it has loaded the
first time, and
i refresh almost immediately speed is normal again ...

How or why is this happening?

Frizzle.

Mar 8 '06 #1
6 1413
frizzle wrote:
Hi group,

I have a site, which content is mostly based on what it finds in a
mySQL database.
All queries etc. are performed by PHP. Somehow, no matter what section
of the
site (still in test fase) i access, either small, with little DB info,
or bif with big DB info,
it seems that when i haven't accessed the page in at least 5 minutes,
access it again
the database is a lot slower the first load.
As if it has to wake up, and get started again. When it has loaded the
first time, and
i refresh almost immediately speed is normal again ...

How or why is this happening?

Frizzle.


After you load it the first time, the info probably is in the cache -
and MySQL just pulls it from there.

Sounds like you need to look into why your first query runs so slowly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 8 '06 #2
Could be connection overhead. The PHP has to connect to the database
using the TCP connection on first connect. After that the connection is
kept alive for a short period of time for use in subsequent requests.
But this should only really be an issue if the mysql server is on a
seperate machine on a rather slow network.

Alternatively it could be the cache on the database server. On first
load the data has to be loaded from the hard disk into a memory cache
where it is kept for a short period of time. Subsequent accesses can
then draw from the cache directly.

Either way, when your site goes live and you are getting plenty of hits
you shouldn't encounter these delays as all connections and caches
would be kept intact by the load itself. Also, there is most likely
something in your code which is sub-optimal. Analyse your queries
closely and see where you can make improvements. Move as much
processing as possible to the database site when it will result in less
data moving between PHP and MySQL.

You might also want to consider moving to a more capable database such
as PostgreSQL. PostgreSQL has some great features you can leverage for
creating smarter queries such as PL/pgSQL, triggers, stored procedures
and lots more.

-Robert
frizzle wrote:
Hi group,

I have a site, which content is mostly based on what it finds in a
mySQL database.
All queries etc. are performed by PHP. Somehow, no matter what section
of the
site (still in test fase) i access, either small, with little DB info,
or bif with big DB info,
it seems that when i haven't accessed the page in at least 5 minutes,
access it again
the database is a lot slower the first load.
As if it has to wake up, and get started again. When it has loaded the
first time, and
i refresh almost immediately speed is normal again ...

How or why is this happening?

Frizzle.


Mar 8 '06 #3
frizzle wrote:
it seems that when i haven't accessed the page in at least 5 minutes,
access it again the database is a lot slower the first load.


Is it a shared server with limited memory?

If so, it may be that when your data hasn't been accessed in a while it is
swapped out of main memory onto disk to make way for other people's data;
then when requested again, it needs to be loaded back into memory.

It's probably something along those lines.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Mar 8 '06 #4

Toby Inkster wrote:
frizzle wrote:
it seems that when i haven't accessed the page in at least 5 minutes,
access it again the database is a lot slower the first load.


Is it a shared server with limited memory?

If so, it may be that when your data hasn't been accessed in a while it is
swapped out of main memory onto disk to make way for other people's data;
then when requested again, it needs to be loaded back into memory.

It's probably something along those lines.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact


Thanks all, i understand there isn't really anything i can do about it
.... :(
Except for switching DB-system (not really an option now) or optimize
the PHP codes, which i already made as good as i'm capable of at the
moment ...

About the caching of data: if i first 'wake the server up' by accessing
the news
section of the site, and then go to links (both from DB) links is still
a lot faster,
as when visited immediately, though it's not in cache ...
(First load really takes up to 10 secs, second up to 0.8 (still quite
slow), can't be
normal ... )

The site is on a shared host.

Anyway, thanks again!

Mar 8 '06 #5
frizzle wrote:
Toby Inkster wrote:
frizzle wrote:

it seems that when i haven't accessed the page in at least 5 minutes,
access it again the database is a lot slower the first load.


Is it a shared server with limited memory?

If so, it may be that when your data hasn't been accessed in a while it is
swapped out of main memory onto disk to make way for other people's data;
then when requested again, it needs to be loaded back into memory.

It's probably something along those lines.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Thanks all, i understand there isn't really anything i can do about it
... :(
Except for switching DB-system (not really an option now) or optimize
the PHP codes, which i already made as good as i'm capable of at the
moment ...

About the caching of data: if i first 'wake the server up' by accessing
the news
section of the site, and then go to links (both from DB) links is still
a lot faster,
as when visited immediately, though it's not in cache ...
(First load really takes up to 10 secs, second up to 0.8 (still quite
slow), can't be
normal ... )

The site is on a shared host.

Anyway, thanks again!


Switching DB systems won't help. Every major DB implements some kind of
caching mechanism for performance reasons.

But it may not be the data which is cached, either. It might be the db
server has been swapped out, or any number of things. I really wouldn't
expect a different db server to act differently - because I don't think
it's a MySQL problem.

But since you're on a shared host, there's no way for you to
troubleshoot the problem. Have you tried talking to your hosting
company's support group? And if they can't help you, find a competent
hosting company.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 8 '06 #6
In message <yr********************@comcast.com>, Jerry Stuckle
<js*******@attglobal.net> writes
<snip>

But it may not be the data which is cached, either. It might be the db
server has been swapped out, or any number of things. I really
wouldn't expect a different db server to act differently - because I
don't think it's a MySQL problem.

But since you're on a shared host, there's no way for you to
troubleshoot the problem. Have you tried talking to your hosting
company's support group? And if they can't help you, find a competent
hosting company.


Has the OP tried this at home? E.g. if he has a PC at home set up with
the same database & scripts, does he have the same problem? If not then
in my view that points the finger at the hosted database, but if he has
it at home them maybe it *is* the query tuning etc.

BTW is he *sure* that the schemas of the two databases are identical?
It's not unknown for people to create indexes on test databases to
resolve performance issues and then forget to create them on the live...
:)

--
Surfer!
Email to: ramwater at uk2 dot net
Mar 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : ...
6
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
8
by: Kamlesh | last post by:
Hi, How do I know the physical database path of a database. When I goto the DB2INSTANCE users's directory (/home/db2inst1), I see following folders: /db2inst1/NODE0000/SQL00001...
1
by: pintur | last post by:
The message is: SQL1036C Errore di I/O durante l' accesso al database. SQLSTATE=58030 what is the proble? what for restore tables? thanks
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
8
by: morleyc | last post by:
Hi, until recently i was quite happy to add data sources from mssql database in visual studio and drag the datasets directly onto the form this creating a directly editable form which worked well....
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Laurynn | last post by:
# (ebook - pdf) - programming - mysql - php database applicati # (Ebook - Pdf)Learnkey How To Design A Database - Sql And Crystal Report # (ebook-pdf) E F Codd - Extending the Database Relational...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.