All,
I am in the process of tweaking and tuning my PHP scripts, and am starting
to look in tweaking my indexes in my MySQL tables.
I have found many, many articles on the topic and have applied quite a few
tips from them and have increased the
overall speed of the site. Question I have is, there are quite a few queries
that I have that really don't have any
"index-able" fields, with the exception of a specialized "sort" field I
guess.
Anyways, should an index of some sort (i.e. single, multiple, etc.) be
created for a query like this:
(NOTE: I read the entire result into an array, and will process it on the
PHP page, basically creating
tables and such from the results).
$sql_string = "SELECT SQL_CACHE a,b,c,d,e,f,g,h FROM mytable ORDER BY
sortid";
$tb_array = table_array(&$s ql_string);
function table_array ($sql_string)
{
$result = mysql_query($sq l_string) or die("bang");
$num_rows = mysql_num_rows( $result);
$num_fields = mysql_num_field s($result);
$j = 0;
$x = 1;
while ($row = mysql_fetch_arr ay($result)) {
for($j = 0;$j < $num_fields;$j+ +) {
$name = mysql_field_nam e($result, $j);
$arr[$x][$name] = $row[$name];
}
$x++;
}
return array('arr' => $arr, 'rows' => $num_rows, 'fields' => $num_fields);
}
The only index I can think of to create might be on the "sortid" field.
I don't really have a need for a WHERE clause (I don't think), since I am
returning the entire result.
Any ideas ? Thanks.
I am in the process of tweaking and tuning my PHP scripts, and am starting
to look in tweaking my indexes in my MySQL tables.
I have found many, many articles on the topic and have applied quite a few
tips from them and have increased the
overall speed of the site. Question I have is, there are quite a few queries
that I have that really don't have any
"index-able" fields, with the exception of a specialized "sort" field I
guess.
Anyways, should an index of some sort (i.e. single, multiple, etc.) be
created for a query like this:
(NOTE: I read the entire result into an array, and will process it on the
PHP page, basically creating
tables and such from the results).
$sql_string = "SELECT SQL_CACHE a,b,c,d,e,f,g,h FROM mytable ORDER BY
sortid";
$tb_array = table_array(&$s ql_string);
function table_array ($sql_string)
{
$result = mysql_query($sq l_string) or die("bang");
$num_rows = mysql_num_rows( $result);
$num_fields = mysql_num_field s($result);
$j = 0;
$x = 1;
while ($row = mysql_fetch_arr ay($result)) {
for($j = 0;$j < $num_fields;$j+ +) {
$name = mysql_field_nam e($result, $j);
$arr[$x][$name] = $row[$name];
}
$x++;
}
return array('arr' => $arr, 'rows' => $num_rows, 'fields' => $num_fields);
}
The only index I can think of to create might be on the "sortid" field.
I don't really have a need for a WHERE clause (I don't think), since I am
returning the entire result.
Any ideas ? Thanks.
Comment