views:

200

answers:

1

I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized array as a JSON object in the database. I see that Doctrine has an array column that does similar serialization. Is there any performance benefit to the array column verses having custom json_decode/encode getters and setters? What serialization format is Doctrine using?

+2  A: 

I believe Doctrine uses its own serialisation format, which is similar enough to that used by PHP's serialize()/unserialize() format to be recognisable but not similar enough to be compatible.

The performance benefit will probably be negligible as both are essentially implode()-like operations and PHP is pretty quick with string manipulation. There is however the overhead of Doctrine itself and the actual database transaction too, and these are much bigger factors when considering any optimisation.

If you're hydrating Doctrine objects from the serialized string, then Doctrine provides a method for its own serialised format which is perhaps quicker, although again is not a major bottleneck for computation.

Raise