For best DB performance should I serialize all theme options together or by type?

If my theme has a lot of options is it better to store all options in one database entry, or to use a databse entry for each group of options? IE would I name all options like this themeSlug[optionType_specificOption] or like this: themeSlug_optionType[specificOption]?In the latter example if I need the settings for my post slider I would do $sliderOptions = get_option('themeSlug_slider');.

I guess my question is do I see any performance benefit to making several smaller queries vs one large query for my options? Are their any other advantages/disadvantages to grouping my options into different entries?

Related posts

1 comment

  1. All options with autoload = yes (default) are fetched very early in one query. So the number of options does affect performance only marginally.

    Split options if you don’t need everything on every page load. With …

    add_option( 'option_name', 'option_value', '', 'no' );
    

    … you can set options that aren’t loaded before you actually call get_option().

Comments are closed.