Re: Performance of dynamically generated select boxes
| From: | CPT John W. Holmes | Date: | Wed, 29 Oct 2003 18:43:41 +0000 |
| Subject: | Re: Performance of dynamically generated select boxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168032@lists.php.net to get a copy of this message | ||
From: "Luis Lebron" <llebron@sigmatech.com>
> I am rebuilding a php application to handle a higher load. The previous
> programmer had created a series of dynamically generated select boxes
using
> a mysql table. Would it be faster or less resource intensive to create a
> series of arrays to generate the select boxes and avoid the database
> queries. I've done some informal testing using Pear Benchmark and it seems
> the array based script usually takes less time.
Yeah, that would be quicker, provided the contents don't change to often.
You should build a cache system where the arrays are recreated every so
often so they stay current (or on demand).
Take a look at var_export(). It will return valid PHP code that you can
write to a file and then include() to recreate your arrays. If the file
doesn't exist, trigger the function to create the array file, etc...
---John Holmes...