How to analyze mySQL performance in PHP pages (memory proble

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
guarriman
Forum Commoner
Posts: 44
Joined: Thu Nov 03, 2005 4:11 am

How to analyze mySQL performance in PHP pages (memory proble

Post by guarriman »

Hi.

Working with PHP 4.4.2 and MySQL 4.1.19, I'm suffering some memory problems on my server (memory allocations, slowness), and would like to know if my mySQL queries are well-designed in terms of memory.

My website allow users to register and to share items with several degrees of privacity, so each time someone accesses webpages I must check which items are public or not, by using SQL queries. I've written code by myself so I may've done some mistakes.

Is there any way to check this mySQL performance? Some tips?

Thank you very much.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Be sure the fields in WHERE and JOIN clauses are indexed. That should help quite a bit in most situations.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Use EXPLAIN queries to figure out which fields need indexing. If you make a lot of indexes you'll produce even slower results.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

feyd wrote:indexes
That was on purpose?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

huh?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

I thought the plural of 'index' was: 'indices'? :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's both, actually.
Post Reply