I managed to hunt down a serious site slowdown issue we have been having since we imported roughly 100K articles into our site, and it seems to be a fairly critical CCK nodereference bug (for content heavy sites, anyway).

When you have a CCK nodereference field on a content type and *don't* use it (read: leave the field blank) the function _nodereference_potential_references builds and returns an array of *every* node (in our case, WHERE type= 'article') of that reference type (again in our case, 'article', all 100K of them!). Specifically, multiply this 100K node array times the number of node reference fields you have (yet again in our case: related story, related audio, related video and related images).. that's 400K nodes in 4 huge arrays.

Conversely, when the field is used and you enter one or more references, it will only build and return an array containing only the nodes you specified, which is normal and good.

Essentially this bug makes all nodereference fields required fields if you want your site to not slow to a crawl (normally it runs our of memory or times out) when editing or creating content.

I imagine a sleek fix for this would be to return an empty array when no $ids or $limit is passed, but I don't know enough about Drupal in general to make this call.

Anyone?

Comments

jcfiala’s picture

Status: Active » Needs review
StatusFileSize
new1.31 KB

Yeah, this is a problem for us. Here's a patch reflecting the changes we've made to nodereference.module to fix this problem.

It's pretty simple - basically just exiting out if there's no processing to do.

yched’s picture

StatusFileSize
new4.76 KB

Didn't check, but think this would break option-based widgets (select, checkbox / radios...). I'd rather avoid changing the behavior of _nodereference_potential_references() anyway.

Could you test the attached patch ? I'd like to have this included in the forthcoming 2.2 release.

yched’s picture

Status: Needs review » Fixed

Works fine on my setup, I went ahead and committed the patch in #2.

andershal’s picture

Works fine on my site too... thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.