MySQL SELECT performance suggestions

From: Date: Wed, 10 Jan 2001 19:58:37 +0000
Subject: MySQL SELECT performance suggestions
Groups: php.general 
Request: Send a blank email to php-general+get-33757@lists.php.net to get a copy of this message
Could someone suggest some options here for performance improvement? I have a table with about 300,000 entries/records by 7 columns/fields. All of the information varies from entry, but only one field can be declared as UNIQUE. I have PHP perform SELECT queries on the table, and I need to display the results in a format of: "viewing $top to ($top+$depth) of $numrows found" I haven't found a way to determine $numrows without performing a second SELECT in this format: $numrows = mysql_num_rows (db_query("SELECT * FROM products WHERE $product_query")); if ( $numrows < $depth ) { $depth = $numrows; } $qid = db_query("SELECT * FROM products WHERE $product_query LIMIT $top, $depth"); So, this takes about twice as long as it would without figuring the $numrows. Does anyone have any suggestions as far as what can be done to speed this up? Assume that the table in question is optimized with indexing and UNIQUE values. Thanks. Lee Howard

« previous php.general (#33757) next »