Re[2]: [PHP] config tests
| From: | Uros Gruber | Date: | Sun, 10 Aug 2003 09:23:12 +0000 |
| Subject: | Re[2]: [PHP] config tests | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159023@lists.php.net to get a copy of this message | ||
Hi,
You don't need to do that way. I also test speed if you select for
example 5 diferent values. You get 5 queries.
I just select everything in one place then I use
$config['config_color']
or you can write some function getConfig('config_color') to get
selected value from this array.
I use text to store this because there's no need to index this.
I also make some script to easy add and remove config values.
But I agree with you that 1st one is more flexible.
--
Best regards,
Uros
Sunday, August 10, 2003, 10:32:13 AM, you wrote:
JWH> Uros Gruber wrote:
>> Hello!
>>
>> I just made some speed tests getting configuration from DB.
>>
>> For now I figured 2 ways doing this.
>>
>> 1. One value in each row
>>
>> id | name | val
>> ----------------------
>> 1 | name1 | value1
>> ........
>>
>> 2. using serialize($config) and saving this in one row.
>> $config is predefined array of configuration.
>>
>>
>> I test this with 100 config values. First I read all 100 rows for 1st
>> example, then I read only one row and then unserialize this to get
>> array.
>>
>> Here is result:
>>
>> 1st example 0.0478450059891 86.74%
>> 2nd example 0.0073139667511 13.26%
>>
>> There you can see speed of second example. I wan't to know what do you
>> think about this. And what's your solutions of reading config from DB.
>> I saw that many big project still use first example.
>>
JWH> Question: How many people selected 'blue' for their config color?
JWH> 1. SELECT COUNT(*) FROM Table WHERE config_color = 'blue';
JWH> 2. ?? SELECT COUNT(*) FROM Table WHERE serialized_column LIKE
JWH> '"config_color";s:4:"blue";'
JWH> Basically, method 1 is more flexible. With method 2, you'll need to
JWH> store it in a TEXT column or hope your serialized value never goes over
JWH> 255 characters.