View Single Post

   
  #9 (permalink)  
Old 05-05-2008, 05:51 AM
Jerry Stuckle
 
Posts: n/a
Default Re: Need help performance tuning mysql db

weheh wrote:
> Hi Jerry,
>
> Thanks for your rapid response. Much appreciated. I've read the tuning
> manual at this point and it is full of good suggestions. I've started by
> tinkering with my swap space, but haven't gotten any positive results, yet.
> My server has 4GB of memory but only 1GB is getting used, max.
>
> A few questions:
>
> - I find that my cgi-bin script that does a database access refreshes my
> browser in a herky-jerky fashion. I'll get a bunch of data. Then a long
> pause. Then a bunch of data. Then wait again. Etc. What could be causing
> that?
>


That's simple. Both PHP and your server buffer data for performance
reasons. When PHP's buffer fills, it sends the data to the server.
Then when the server's buffer fills, it sends the data to the client.

> - My DB tables are all built using CREATE TABLE. Primary tables have keys.
> There are some many to many tables that have no keys. For instance: user is
> member of group that has acess to record of another table that can belong to
> multiple groups. I don't really understand what MYISAM and INNODB are and
> what they can do for me. Do I need to understand that to tune performance?
> My queries seem straightforward and are all done with LEFT JOINs. Nothing
> too fancy.
>


All tables should have primary keys. The key may not be a unique
column. For instance, for a table creating a multi-multi link between a
table of employees and a table of skills, I might have two columns -
"employeeid" and "skillid". The primary key would consist of both columns.

MyISAM and InnoDB are two different engines for storing the underlying
data. Each has its advantages and disadvantages - hence two engines.
For instance, MyISAM is generally faster, but InnoDB enforces
referential integrity. You really should understand the differences so
you pick the appropriate engine.

> - Can EXPLAIN be run from within a cgi-bin script? I must learn this
> capability.
>


Sure. Run it just like any other MySQL statement - just place EXPLAIN
in front of the SELECT keyword to get the EXPLAIN output. I generally
run it from PHPMyAdmin, though. Easier than writing even a short CGI.

> Sorry for the top-post.
>
> R
>
>> Richard,
>>
>> The MySQL manual has a lot of good information on tuning.
>>
>> But Michael gave you the most important tip. Before you do ANYTHING ELSE,
>> run EXPLAIN on each of your queries. Look at the output and find those
>> which are doing full table scans.
>>
>> You can't specify how many queries can be run simultaneously, but you can
>> specify the number of connections which can be active concurrently in your
>> my.ini file.
>>
>> But I highly doubt that's your problem. Most likely your problem is
>> inefficient database design and/or inefficient queries.
>>
>> And no, MySQL does not lock tables for SELECT statements. What gets
>> locked when you update the database depends on the request and engine
>> being used.
>>
>> P.S. Please don't top post. Thanks.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstucklex@attglobal.net
>> ==================
>>

>
>
>



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote