Here is the query :
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
we could easily change "ORDER BY d.reindex ASC, n.nid ASC" to "ORDER BY d.reindex ASC, d.sid ASC" since we are using "d.sid = n.nid" in the query
Comments