Measure database query bandwidth usage?

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
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Measure database query bandwidth usage?

Post by Chalks »

I'm not sure if that topic makes sense...

The more I get into php, the larger my databases get. I wonder why that is.... I'm working on a quick project for a Spanish class, and my database will end up having around 500-700 entries in it. each entry fills two varchar(100) fields, one varchar(3) field, and two int fields (one auto incrementing). I use the following code to build two arrays:

Code: Select all

$sql = buildsql();
$data = mysql_query($sql) or die(mysql_error());

while($result = mysql_fetch_array($data))
{
  $spanray = array_merge($spanray, array($result[0]));
  $englray = array_merge($englray, array($result[1]));
}
The user will have the option of selecting anywhere from 30ish entries to the entire database. How hard of a hit could that create on my server? I mean, what if 30 people ran a query selecting the entire database every hour? I don't really expect even that much but... hey, it could happen. Is there any way to measure what kind of bandwidth the largest query takes up?


Thanks. :)








Edit: Oh yeah, as a side note... is

Code: Select all

SELECT FROM table WHERE (something=1 OR something=2) AND (nothing=3 OR nothing=3)
the same thing as

Code: Select all

SELECT FROM table WHERE something=1 OR something=2 AND nothing=3 OR nothing=3
? The former seems to work just fine >.>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Two things. First, your database probably has statistics available that can help you determine how much data is being send for queries. Check the manual. Second, I would recommend only worrying about performance in only a general way. The design is much more important and whereas good designs can almost always be optimized, designing for performance will usually force decisions that limit good design.
(#10850)
Post Reply