I am currently building a Wordpress plugin to fulfil WooCommerce orders for a "virtual" product. Once the payment is confirmed, I make an API call that returns a large (~50 values) array of technical data about a vehicle. This is then stored as meta data for the order, so it can be displayed to the customer and also retrieved at a later date.

I have read lots to suggest that serializing meta data and storing it as a single field is a bad idea, and makes life difficult in the long run. But it makes much more sense to me in this case to serialize the data - optimising performance and reducing the number of DB entries by 50x. I don't need to query by the contents of the data, it is just a self-contained data object, if you will, that will always be accessed in its entirety.

$response = wp_remote_get($endpoint);
$body = wp_remote_retrieve_body($response);
$obj = json_decode($body, true);
$data = $obj["Response"]["Payload"]; // Array of ~50 strings
update_post_meta($order, 'vehicle_data', $data);

Can somebody reassure me that this is sensible, as I'm now worried from all I've read that this may trip me up later.


  • Where did you read that it would be bad to use serialized data? I am thinking that if this is bad or not depends on how the data will be used and as you say instead of making many requests you can just do one and then deserialize the retrieved data. Do you have a link or something to the place where you read that this would be a bad idea? Thinking of storing data in separate meta fields I guess you still could use only one query using a LEFT JOIN. Commented Sep 7, 2020 at 13:04
  • On various stackexchange answers, contributors have suggested it causes more problems than it's worth. But thank you for your reassurance! I'll stick with serializing the array. Commented Sep 7, 2020 at 13:27

1 Answer 1


Serialized wp_watevermeta data causes performance problems only if you need to search for it. For example if you want to find all the red cars it's faster to use a WP_Meta_Query operation than it is to read each car's deserialized metadata and examine the data structure for the color.

It's slow, sometimes painfully slow, to search serialized data.

It's true that fewer wp_whatevermeta rows are slightly more efficient and easier to troubleshoot than many such rows. Search ability is the only important tradeoff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.