Jump to content

The speed of PHP


naykidd

Recommended Posts

Hi i've created a MySql table which consists of about 10 columns, and im about to start populating it with around 15,000+ entries..

 

The contents of this table are fetched by PHP and different results from the table are displayed on different pages of my site, depending on a certain branding (E.g. a page for bosch, a page for sony, a page for sanyo, but all coming from the same table, which will use a search feature to fetch the relevant information into each page)

 

As its a website, obviously likely that all pages (About 40 brands) would be looked at at the same time by many many people

 

Is this going to be very slow?

If so is it going to be much slower than if i split the tables up into 40 different brands?

Link to comment
Share on other sites

No, you should not definitely create different tables for each brand, becuase you would break lots of database design rules.

 

It's is hard to say, whether it will be slow or fast without any piece of the source code, becuase it depends, how you are going to optimize it. My suggestions:

 

1. Use MySQL indexes properly.

2. Use some sort of pagination in order not to display too many rows on one page.

3. Use unbuffered queries when fetching the data. The original PHP mysql extension buffered all the results in memory and then fetched them from a local memory. It allowed to simulate recursive queries, but it was very inefficient. PDO is much better choice in my opinion.

Link to comment
Share on other sites

Both PHP and MySQL is known to be able to handle a serious amount of users and if both properly optimized you can serve an even more serious amount of users. However chances are that within the first year you won't see that many people online, maybe not even in the first 5 years (depending on findability and marketing). A lot of companies invest in a certain amount of servers which would be able to handle that serious load. However there are very few companies who experience that serious load within the first year (because their user base is only starting to expand), second year is more probable (as you'll already have a user base and returning users).

Link to comment
Share on other sites

3. Use unbuffered queries when fetching the data. The original PHP mysql extension buffered all the results in memory and then fetched them from a local memory. It allowed to simulate recursive queries, but it was very inefficient. PDO is much better choice in my opinion.

 

What has PDO to do with mysql buffering it's queries? PDO stands for PHP Data Objects and is an database abstraction layer (thus making your application only portable across multiple databases vendors).

Link to comment
Share on other sites

PDO stands for PHP Data Objects and is an database abstraction layer ...

 

From the manual

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.
Link to comment
Share on other sites

ignace -> I know what PDO is. And PDO, as a data-access layer, uses unbuffered queries only, contrary to the historically first PHP mysql extension, where such option appeared in PHP 4 and many programmers simply don't know about it, still using ordinary mysql_query() function, even if they don't need the buffering features.

Link to comment
Share on other sites

ignace -> I know what PDO is. And PDO, as a data-access layer, uses unbuffered queries only, contrary to the historically first PHP mysql extension, where such option appeared in PHP 4 and many programmers simply don't know about it, still using ordinary mysql_query() function, even if they don't need the buffering features.

 

I didn't knew that, I really thought all PDO did was to provide database portability. Well, you really learn something new everyday ;)

Link to comment
Share on other sites

ignace -> I know what PDO is. And PDO, as a data-access layer, uses unbuffered queries only, contrary to the historically first PHP mysql extension, where such option appeared in PHP 4 and many programmers simply don't know about it, still using ordinary mysql_query() function, even if they don't need the buffering features.

 

As far as I'm aware, buffering options are available to programmers for the PDO. But they're not enabled by default. PDO will NOT make your queries faster. In fact, it is actually slower than mysql_query.

Link to comment
Share on other sites

  • 3 weeks later...

As far as I'm aware, buffering options are available to programmers for the PDO. But they're not enabled by default. PDO will NOT make your queries faster. In fact, it is actually slower than mysql_query.

 

May i know to what extent is mysql_query slower than PDO. And may i ask what exactly PDO does and how does it differ from mysql_query. I tried re-reading this topic, but couldn't get the notion of PDO  :confused: So will someone please elaborate on whatever is being discussed here. *thank you*  :shy:

Link to comment
Share on other sites

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.