Welcome to WebmasterWorld Guest from 54.158.51.150

Forum Moderators: open

Message Too Old, No Replies

How to make a SPEEDY database

     
4:55 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



I've recently put together a new site using PHP and MySQL.

My site load times are horrible and thus leads me to ask what determines database speed?

1. The number of connections to the database? For instance I have some portal pages that have 5 recordsets on a single page.

2. Type of query? (i.e. simple vs. complex)

3. The size of the database (mine is VERY small at this point and that is why I am troubled) Also I am the ONLY users accessing the info as well.

Thoughts?

5:23 pm on Sep 23, 2005 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



first off are you sure it is the database that is slowing you down?

i test this by writing the time to a variable, looping through 100s of queries/connections in the code then getting another time variable,

subtract the two times to see how long the queries took?

...

if you find it is still the db server that is the slow point, then optimising your queries can be very important (do a search on this - the way complex queries are written can make a very big difference)

with mysql i open then close it as quick as possible but i have very fast pages on shared host environments that are making 6 db connections, so i don't think that in itself is a problem
[side note - with sqlServer i just open one connection and reuse it on the page as often as i need then close it at the end of the page]

... of course the db server could just be overloaded with other people using it if you are sharing it, even if your own queries are honed to perfection!

7:03 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



or there could be something horribly wrong with your PHP code in general. Happened to me once,darn loops :)
6:54 pm on Sep 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



1: How often does the data in the database change?

2: Could the index page with the data be published as a static page periodically rather than having each user load it fresh every time they hit the site?

The first question is a very important one, especially if your site is going to be a busy one. The second is a potential solution.

It sounds like the SQL query is doing a big query across all tables at the same time rather than a set of simple, and fast, queries.

If you could post the SQL, this could be established.

Regards...jmcc

 

Featured Threads

Hot Threads This Week

Hot Threads This Month