db-queries

This is a discussion on db-queries within the PHP Language forums, part of the PHP Programming Forums category; Hello, some little questions relating LAMP (PHP 4.3.4, MySQL 3.x, Apache): I'm trying to build a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-27-2005
Bernd Kohler
 
Posts: n/a
Default db-queries

Hello,

some little questions relating LAMP (PHP 4.3.4, MySQL 3.x, Apache):
I'm trying to build a community website which needs many db-querys for lots
of concurrent users.
Therefore I'm always using:
$ergebnis = mysql_query ($sql) or die (mysql_error());
while ($row = mysql_fetch_array($ergebnis))
{
$myvar = $row['column_xy'];
}

Is there a limit for db-connections under MySQL3.x?
What happens if hundreds of users are accessing these pages simultaneously?
I heard MySQL breaks down if there are more than 200 users!?

Is there a better/more efficient way for the db-queries under PHP4?
How efficient would it be to write all possible db-results into
session-variables in order to keep the number of queries low?
What about performance using many session-variables?

Thank you very much in anticipation!
Bernd




Reply With Quote
  #2 (permalink)  
Old 05-27-2005
Mike Willbanks
 
Posts: n/a
Default Re: db-queries

Bernd,

> some little questions relating LAMP (PHP 4.3.4, MySQL 3.x, Apache):
> I'm trying to build a community website which needs many db-querys for lots
> of concurrent users.
> Therefore I'm always using:
> $ergebnis = mysql_query ($sql) or die (mysql_error());
> while ($row = mysql_fetch_array($ergebnis))
> {
> $myvar = $row['column_xy'];
> }
>
> Is there a limit for db-connections under MySQL3.x?
> What happens if hundreds of users are accessing these pages simultaneously?
> I heard MySQL breaks down if there are more than 200 users!?


First off 3.x is not the MySQL installation you should be using. 4.0 or
4.1 you should be using now. Also your PHP installation is dated where
PHP is at version 4.3.11.

Now as for users, I have never had MySQL break down. I also have 50
websites that run off of one database with one administration panel.
These sites get fairly heavy traffic.

Now what you should pretty much do is Cache your queries so you are not
always querying the database. Only query when you need to. Make use of
JOIN statements, so you are not constantly querying for data that could
be in one query. Sometimes these JOINs can get a bit messy because some
of them are INNER JOINS some are LEFT OUTER JOINS etc.. And you end up
with a paragraph long query. But simply, it runs much faster.

Make sure you have index's on certain id's and things you will be
looking up regularly such as usernames and passwords, this allows you to
do an index query. These are normally very quick.

Also as for the connection limit on MySQL you can change the threshold
on that in the config file. Also you might want to think about reusing
your connection PConnect. For me this works much better, but for some
they experience problems.

Mike
Reply With Quote
  #3 (permalink)  
Old 05-28-2005
Bernd Kohler
 
Posts: n/a
Default Re: db-queries

Thanx!!
But what do you mean by caching the queries?
I'm already using many JOINs to keep the number of queries as low as
possible.
What do you think about the session-variables? Can they be handled quick
enough or will they slow down the server?

>
> First off 3.x is not the MySQL installation you should be using. 4.0 or
> 4.1 you should be using now. Also your PHP installation is dated where
> PHP is at version 4.3.11.
>
> Now as for users, I have never had MySQL break down. I also have 50
> websites that run off of one database with one administration panel. These
> sites get fairly heavy traffic.
>
> Now what you should pretty much do is Cache your queries so you are not
> always querying the database. Only query when you need to. Make use of
> JOIN statements, so you are not constantly querying for data that could be
> in one query. Sometimes these JOINs can get a bit messy because some of
> them are INNER JOINS some are LEFT OUTER JOINS etc.. And you end up with a
> paragraph long query. But simply, it runs much faster.
>
> Make sure you have index's on certain id's and things you will be looking
> up regularly such as usernames and passwords, this allows you to do an
> index query. These are normally very quick.
>
> Also as for the connection limit on MySQL you can change the threshold on
> that in the config file. Also you might want to think about reusing your
> connection PConnect. For me this works much better, but for some they
> experience problems.
>
> Mike



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0