? 312393-node-update-index-slow.patch ? modules/search/search.module-test Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1088 diff -u -p -r1.1088 node.module --- modules/node/node.module 29 Jul 2009 06:39:34 -0000 1.1088 +++ modules/node/node.module 29 Jul 2009 19:25:12 -0000 @@ -993,6 +993,17 @@ function node_save($node) { module_invoke_all('node_' . $op, $node); + if ($op = 'update') { + // Ensure every node has a corresponding entry in search_dataset. + db_insert('search_dataset') + ->fields(array( + 'sid' => $node->nid, + 'type' => 'node', + 'data' => '', + 'reindex' => 0, + )); + } + // Update the node access table for this node. node_access_acquire_grants($node); @@ -2032,7 +2043,7 @@ function node_page_view($node) { function node_update_index() { $limit = (int)variable_get('search_cron_limit', 100); - $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit); + $result = db_query_range("SELECT d.sid as nid FROM {search_dataset} d WHERE d.type = 'node' AND d.reindex <> 0 ORDER BY d.reindex ASC", 0, $limit); foreach ($result as $node) { _node_index_node($node); Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.359 diff -u -p -r1.359 system.install --- modules/system/system.install 28 Jul 2009 19:18:08 -0000 1.359 +++ modules/system/system.install 29 Jul 2009 19:25:18 -0000 @@ -2257,6 +2257,16 @@ function system_update_7029() { } /** + * Add an index to search_dataset for 'type' and 'reindex' fields, and ensure each node has an entry in the search dataset. + */ +function system_update_7030() { + $ret = array(); + db_add_index($ret, 'search_dataset', 'type_reindex', array('type', 'reindex')); + db_query("INSERT INTO {search_dataset} (sid, type, reindex) SELECT nid AS sid, 'node' AS type, 2147483647 AS reindex FROM d_node"); + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */