This is in node.admin.inc: function node_admin_nodes()

  // Enable language column if translation module is enabled
  // or if we have any node with language.
  $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM {node} WHERE language != ''")));

This query is a performance hit for sites with lots of nodes.

mysql> SELECT COUNT(*) FROM node WHERE language != '';
+----------+
| COUNT(*) |
+----------+
|  3901948 | 
+----------+
1 row in set (57.15 sec)

The number that is returned is unimportant; it will just evaluate to a boolean. So we could use other queries in its place, like this:

mysql> SELECT language FROM node WHERE language != '' LIMIT 1;
+----------+
| language |
+----------+
| en       | 
+----------+
1 row in set (0.00 sec)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

robertDouglass’s picture

Actually, that query didn't make it much better, but an index does:

mysql> alter table node add index node_language (language);

robertDouglass’s picture

Status: Active » Closed (duplicate)

Oops, I'd already reported this: http://drupal.org/node/374035

c960657’s picture

Status: Closed (duplicate) » Needs review
FileSize
1.48 KB
1.57 KB

Even with the index added in #373897: admin/content still has sortable author column resulting in SQL errors, I still think we should optimize the query to use LIMIT 1 like we do elsewhere in core.

Status: Needs review » Needs work

The last submitted patch, 375064-node-language-D6-1.patch, failed testing.

c960657’s picture

Status: Needs work » Needs review

Test bot failed to test the D6 patch.

catch’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.57 KB

Looks good, re-uploading D7 patch for the bot.

Dries’s picture

Status: Reviewed & tested by the community » Needs review

Committed to CVS HEAD. Not marking this fixed yet because I do have a follow-up question:

+++ modules/node/node.admin.inc	10 Mar 2010 10:23:55 -0000
@@ -405,21 +405,21 @@ function node_admin_nodes() {
+  $multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE language <> :language", 0, 1, array(':language' => LANGUAGE_NONE))->fetchField());

Any reason we want a query? It seems like the module_exists() check might be sufficient? One might argue that that would be the proper behavior anyway.

catch’s picture

If you disabled translation module, you could still have multilingual nodes and want to filter on them, however I don't see a particular reason to provide a UI for that in core since it's something that can easily be done from contrib. Also this should really be something that's hooked in in Drupal 8, it's sad that we have node module doing a module_exists().

podarok’s picture

subscribe

Azol’s picture

subscribe

jnpwebdeveloper’s picture

This is crazy! I am not a Drupal pro but this made a really noticeable difference in my test environment. I didn't even have any nodes in my installation and it was causing a bottle neck. I saw that this was a major hang up when checking my performance logs.

Why the heck is there a check for language support if the majority of sites don't even use this feature. This should only be done if the module is installed or variable is set.

montesq’s picture

If you disabled translation module, you could still have multilingual nodes and want to filter on them

IMHO, if you disable translation, you should not expect to have any information about the node language anywhere in Drupal...
That is why I agree to say that checking module_exists('translation') must be sufficient.

c960657’s picture

You don't have to use the Translation module in order have nodes with different languages. The Locale module defines a multi-lingual setting per node type, locale_multilingual_node_type().

Perhaps a better check is to remove the current condition and replace with a check to see if any content type allows multi-lingual nodes, i.e. loop over all language_content_type_... variables.

  • Dries committed 4bf9e43 on 8.3.x
    - Patch #375064 by c960657, catch: Performance: Multilanguage checking...

  • Dries committed 4bf9e43 on 8.3.x
    - Patch #375064 by c960657, catch: Performance: Multilanguage checking...

  • Dries committed 4bf9e43 on 8.4.x
    - Patch #375064 by c960657, catch: Performance: Multilanguage checking...

  • Dries committed 4bf9e43 on 8.4.x
    - Patch #375064 by c960657, catch: Performance: Multilanguage checking...
joseph.olstad’s picture

Issue summary: View changes
Status: Needs review » Fixed

This issue was fixed back in January 2011 by non-other than Dries and catch and c960657.

Dries committed this 2011-01-12
4bf9e43e (Dries Buytaert 2011-01-12 23:09:13

Status: Fixed » Closed (fixed)

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