Hi everyone, I was just wondering if you all could give me some tips on efficient coding and database optimization. Reason being, my webhost recently turned off my MySQL access cause I was using up too many of the available connections.
How I code is the basic,
while ( fetch object or array )
{
print nice n' purty;
}
.. the way most all tutorials teach you how to do it. I guess what I'm wondering is how intensive is it to do this, fetching say 50 records at a time with about 4 fields, say, an ID number, a relatively short filename stored as a varchar, a 255 character description stored as a varchar, and maybe a short category also stored as a varchar on a page getting about 20-25,000 page views per day. Enough to cripple MySQL on a shared server? Doesn't seem like it should be, but is there a more efficient way? Any pointers, tips, links etc greatly appreciated.
One other thing while I'm at it, when or where should you call the mysql_close( $connection ) and mysql_free_result( $result ) functions? Reguardless of having called these at the end of any and all scripts that pull records from my database, the connections still were not closing. My webhost admin guy said that some were even staying open for a couple hours at a time.
TIA,
Justin
How I code is the basic,
while ( fetch object or array )
{
print nice n' purty;
}
.. the way most all tutorials teach you how to do it. I guess what I'm wondering is how intensive is it to do this, fetching say 50 records at a time with about 4 fields, say, an ID number, a relatively short filename stored as a varchar, a 255 character description stored as a varchar, and maybe a short category also stored as a varchar on a page getting about 20-25,000 page views per day. Enough to cripple MySQL on a shared server? Doesn't seem like it should be, but is there a more efficient way? Any pointers, tips, links etc greatly appreciated.
One other thing while I'm at it, when or where should you call the mysql_close( $connection ) and mysql_free_result( $result ) functions? Reguardless of having called these at the end of any and all scripts that pull records from my database, the connections still were not closing. My webhost admin guy said that some were even staying open for a couple hours at a time.
TIA,
Justin