[EMAIL PROTECTED] wrote:
Hi,

I have to show 6 of up to 1000 (most likely 200-600) featured products on
my online store.

My first thought was using this query:
$query = mysql_query("
   SELECT p.prod_id, p.prod_name, p.prod_no, pr.price_id, pr.method,
pr.qty, pr.price, pr.sale_price, chp.cat_id
   FROM products as p
   LEFT JOIN prices as pr ON pr.prod_id = p.prod_id
   LEFT JOIN categories_has_products as chp ON chp.prod_id = p.prod_id
   ORDER BY RAND() LIMIT 6
 ");
but I needed 4 to 6 secunds to finish downloading the page.

Then I tried as a solution to grab all featured products from db, store
them as an array in $_SESSION[FEFATURED_PRODUCTS] and then evey time
actually just grab randomly 6 products form the array.
The home page is now much faster, of course, but I'm not sure how "smart"
is keep an array with 1000 elements in $_SESSION?

Thanks for any opinion!
:)

-afan


hello afan,

it is not "smart" at all..

1. array takes valuable computer memory. 1000 (arrays) is a lot. 1 char = 1 byte, 40 chars each string. and several fields. 2. sessions actually store the same on file in the session directory. reading of files is slower and requires a lot of computer overheads.

the sql is easier to use and much efficient.

moreover u must try to use a Profiler. a profiler is a software that gives you more details on all the functions and the time taken and the number of times used. you will be able to determine the frequency of the usage of the function and can improve or developed further the most commonly used functions.

Pear's Benckmark Profiler is easy to install and to use...try it.

Use session only for dynamic data that CANNOT be stored in a database.
like carts, navigation info, or form elements etc.

--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to