Jump to content

Recommended Posts

ok guys im trying to optimise my scripts to run faster, i need some help (noob) :(. im using phpmyadmin to access my info.

here goes....

1. is it better to have all my tables under the one database, or better to have multiple databases?

2. most of my columns are varchar 255, is this ok or is char 255 better? (size isnt an issue, only speed)

3. how do i index my database? iv read up on this but still a bit lost...

4. in phpmyadmin i ran a simple search SELECT * FROM `searchbooks1`

and the query returned results in 0.0009 sec

but when i do this through my website, i.e search for books, it takes ages, is this a server issue?

ok, thats it for now, unless there is anything i missed that will speed up my site.

the site is studyleave.com (mentioned previosuly)
any help would be very much appreciated.

thanks
Link to comment
https://forums.phpfreaks.com/topic/15817-php-speed-and-optimization/
Share on other sites

1, doesn't really matter I suppose it might help some.
2. Lower most basic ones to varchar (80) instead, if it's something that won't require 80 characters limit it even more, whatever it's set to, it makes enough room in memory for that, you don't need it adding the extra memory use datatypes very wisely when building the database.
3. Click on 1 field and click index, don't index more than 2 fields, or it does worst than good.  1-2 htat you call frmo a lot will make it faster.
4. show your script.
[quote]1. is it better to have all my tables under the one database, or better to have multiple databases?[/quote]
I suspect that joins within a single db are more efficient than those across db's, but that's a guess.


[quote]2. most of my columns are varchar 255, is this ok or is char 255 better? (size isnt an issue, only speed)[/quote]
char would be faster as you then get fixed length records. However only set the sizes to that required and not all 255. Query speed is proportional to to the amount of data returned so hundreds of unneccessary spaces is adding to the load,

[quote]4. in phpmyadmin i ran a simple search SELECT * FROM `searchbooks1` and the query returned results in 0.0009 sec but when i do this through my website, i.e search for books, it takes ages, is this a server issue?[/quote]
You were probably already connected to the server so didn't have the overhead of the connection. The longest part of a query is often the db connect. Just do it once per page.

[code]ok, thats it for now, unless there is anything i missed that will speed up my site.[/code]
Where possible use joins instead of subqueries or nested queries..
Only penneth to add is that creating a connection to a database uses huge amounts of system resources.  Purely on a 'be nice to the server' basis I woudl stick to one database.  They are built to take a bot of hammer so don't be scared of having 200 tables in a database - its nothing ;)
most of the things mentioned in this thread are the main things you want to consider for optimization.

but there are other tiny things that can add up and eat up a lot of time.
if you follow general good coding practice, you should be ok.

but there are also other things...things like, using double quotes and single quotes appropriately. not using regular expresions when you can use string functions. running PHP as an Apache module or as a CGI.
[quote author=Barand link=topic=102083.msg406127#msg406127 date=1154287205]
Really shaving off the microseconds there, Koobi
[/quote]

hehe yeah :)

i think it really depends on the situation though. like for example, in this process i'm creating, i would have to loop through something almost 3 million times and 3 million micro seconds can add up but that's an extreme case.


don't think you'd really have to do the things i mentioned in my post, w4seem, just thought i'd cover all bases. you should be fine following the rest of the posts before mine :)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.