admin管理员组

文章数量:1122832

I'm building the analytics script plugin which offers customizations on a settings page. There will be around 20 options in total.

Does it affect the performance negatively if I manage these 20 options separately? So each of them will have a database record instead of storing it all as one.

I remember that all options will get preloaded on every page in WordPress anyway unless explicitly specified not to when registering a setting.

I'm building the analytics script plugin which offers customizations on a settings page. There will be around 20 options in total.

Does it affect the performance negatively if I manage these 20 options separately? So each of them will have a database record instead of storing it all as one.

I remember that all options will get preloaded on every page in WordPress anyway unless explicitly specified not to when registering a setting.

Share Improve this question edited Apr 2, 2024 at 17:15 Ostap Brehin asked Apr 2, 2024 at 17:06 Ostap BrehinOstap Brehin 1517 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

If you are looking for performance and have 20 options so yes it is better to store in 1 option key in serialize() manner.

It shouldn’t affect performance to store each option in a separate row. The PHP application is capable of fetching multiple rows in a single batch and, in fact, WordPress itself stores its settings one per row.

I recommend using the Options API so that WordPress does most of the work for you.

https://developer.wordpress.org/apis/options/

As suggested on the WordPress Forum by one of the team members.

本文标签: When to store store plugin options as a single database record