Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
search.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 May 2008 at 13:07 UTC
Updated:
14 Jul 2012 at 23:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
douggreen commentedAnd here's the patch...
Comment #2
damien tournoud commentedThis sid_type should in fact be a primary key.
The change from index to unique was consciously made during the 6.x development cycle. It lead to some problems (such as collations problems solved in #218403: Duplicate entry errors in search indexer), but it's a good choice.
Comment #3
douggreen commentedI'm not too clear on the differences here. But I do know that the current "unique key" implementation is significantly impacting this DELETE which is done on every single node that is indexed. If you know a better way, please offer the patch. Thanks!
Comment #4
damien tournoud commentedI know a better way: just make this key a primary key.
Comment #5
Anonymous (not verified) commented@Damien: How is Primary key better than a Unique key in this instance?
Comment #6
douggreen commentedA unique key is just a constraint, whereas a primary key is an index. You get no performance gain from constraints, but you do from indexes.
Comment #7
damien tournoud commented@douggreen: In fact, for MySQL the difference is not very clear. MySQL also creates an index for UNIQUE KEY, but it's not clear to me if there is prefix and suffix compression for these indexes, nor whereas MySQL can use it to lookup values. Moreover, PRIMARY KEYS are clustered (the physical order of rows change), whereas other index types are non-clustered.
For the
{search_dataset}particular case, aPRIMARY KEYis what makes sense anyway.Comment #8
douggreen commentedI do know that the unique key in mysql is giving terrible performance on the
DELETE FROM {search_dataset} WHERE sid = %d AND type = '%s', so it surprises me to hear that "MySQL also creates an index for UNIQUE KEY."Comment #9
robertdouglass commentedSubscribe.
Comment #10
lilou commentedReroll patch #1 and add description to update function.
Comment #11
dries commentedCommitted to CVS HEAD. Thanks.
Comment #12
damien tournoud commentedSorry, why removing the unique constraint? It makes total sense!
Comment #13
damien tournoud commentedHere is a revert of #10, changing the unique constraints in search_index and search_dataset by primary keys.
Comment #14
dries commentedI think you're right. Committed the follow-up patch.
Comment #15
damien tournoud commentedSorry, finally forgot to drop the redundant 'word' index in the schema.
Comment #16
mfbThere's an update script in system.install running on the search tables, but search module and its tables may not even be installed! This causes errors at update.php. The update script should be in search.install instead.
Comment #17
damien tournoud commentedOups.
Comment #18
webchickThis no longer applies because of some whitespace changes in #303889: Impossible to update D6 -> D7 but should be a quick re-roll.
Comment #19
chx commentedComment #20
kbahey commentedI tested this on top of #46 in http://drupal.org/node/303889, and that combination made update.php work again.
Comment #21
webchickThird time's a charm? :)
Comment #22
damien tournoud commentedI'm pretty sure this issue will came back to haunt us. A ghost will step in, and say "this is an *horrible* idea, please revert". The only question is: when will that happen?