[wp-hackers] Cloning content from Master site into new sites on a WP Network
otto at ottodestruct.com
Wed Jul 11 19:34:28 UTC 2012
On Wed, Jul 11, 2012 at 2:14 PM, Bill Dennen <dennen at gmail.com> wrote:
> One thing that has puzzled me is the notion that switch_to_blog
> shouldn't be used too often. How often is too often? Is it even
> possible to measure such a thing?
> Put it another way - when is it safe to use, and when is it not? At
> what point does it affect performance?
> Of course, every site is different. So there probably isn't a hard and
> fast rule.
> But, switch_to_blog is a very useful tool. I use it for many things --
> and when combined with things like transients and other caching, I
> don't notice any performance problems.
It becomes a problem when it becomes a problem, basically. :) There's
no hard and fast rule.
The thing is that it's tempting to use it stupidly, in loops and such.
Like, if you wanted to get the latest 10 posts across a multisite
setup, then one might try to loop through all the sites, get the
latest posts from them, then order them up yourself. This might work
fine if you have 4 sites, but when you have 40, or 400, or 4000, then
the same code breaks miserably.
So use it sparingly, basically. Probably not something you want to be
doing on every page load.
More information about the wp-hackers