Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Access optimization betwen Config and ORM related
  • Hi.

    I need to know something even if i have doubts : In case of key => value parameters array related to an ORM object, what drawing is the most optimizied betwen :

    Puts those list in database and build a belong_to relationship

    Or setting a config array with the key=>value pattern

    Someone have some benchmark for an operation like checking if a form value is in the array before insert a new object ? In a case it's a join sql operation, and in the other, getting a file and parse data to find values. I think the config is faster, but because i don't really know how optimised is the config class, i need more serious evidence than my thought.


    Edit : it's automatically assumed we're talking about value the application user will not be able to change. In this case, of course, database is the better thought, no ?
  • HarroHarro
    Accepted Answer
    It all depends on your requirements, so it's not easy to give an answer.

    It would definitely opt for the database. If performance is an issue, it's easy enough to cache it, either to files (which would make it equal to config in terms of performance) or one of the other caching backends.

    In terms of structure, there are a couple of scenario's you could consider:

    - if the number of keys is relatively low and stable, create columns for them, and allow null in case the value does not exist
    - if the number of keys is relatively low but random, and you don't need to do lookups on keys or values, you can choose to store a serialized array. Observer_Typing can automatically unpack it for you, so you can access it as an array.
    - if you have a random number of keys, and they have random values, choose an EAV container.
  • Ok I see, thanks.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion