the

$result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL");

(from search_update_totals)
is very slow (more than 10 minutes!).

My search_total has 14,259 lines
and search_index has 32,533 lines

CommentFileSizeAuthor
#5 query.jpg8.92 KBJirkaRybka
#3 q.jpg25.08 KBhe_who_shall_not_be_named

Comments

drumm’s picture

Status: Active » Postponed (maintainer needs more info)

Please paste the results of this SQL query:

EXPLAIN SELECT t.word AS realword, i.word FROM search_total t LEFT JOIN search_index i ON t.word = i.word WHERE i.word IS NULL;

he_who_shall_not_be_named’s picture

id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL PRIMARY 50 NULL 14489 Using index
1 SIMPLE i ALL word NULL NULL NULL 33063 Range checked for each record (index map: 0x4); No...

he_who_shall_not_be_named’s picture

StatusFileSize
new25.08 KB

... or this

he_who_shall_not_be_named’s picture

Well?

JirkaRybka’s picture

StatusFileSize
new8.92 KB

Just for reference - my site (5.1) have even more in these tables: index - 160358 lines, total - 37943 lines. I tried the query from PhpMyAdmin on the production server, and it took just 0.7878 sec. EXPLAIN from my server attached - seems quite different (!). I've not enough experience to find the problem, but I guess there's something wrong with your install (?)

he_who_shall_not_be_named’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Checked the installation and everything seams OK. (MySQL 4.1.21) Simply, it doesn't want to use the word index from the search_ index. That's it. Commented out the query.

Thank you anyway. Now I know that the problem is not here. Closed the bug.

he_who_shall_not_be_named’s picture

Found It! For a strange reason (maybe the updates from early Drupal versions) the search_total 'word' column was varbinary instead of varchar. Now it works.

Thanks again.

moonray’s picture

Version: 5.2 » 5.10
Status: Closed (fixed) » Active

Just ran into the same problem.
Changing the field type from 'varbinary' to 'varchar' fixed the issue.

It actually brought our server to its knees a few times before we could determine the cause. How did it get to be 'varbinary' in the first place?

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

Not sure where this came from. I searched through the system_install file and the old database.*.inc files from D4, and I don't see any reference to the field type 'varbinary'. I also checked all the definitions/updates to the 'word' column in the 'search_total' table, and they're all of type varchar. Maybe a rogue contrib module changed the column type? Marking as need more info.

Also, you can reduce the number of nodes to index on cron in the search settings.

moonray’s picture

We had it only indexing 10 nodes, and it still hung the server. The problem is not with indexing the nodes, but updating the search totals (counting the amount of times a word appears). It doesn't matter how many new nodes you index, it still reruns those queries each time cron runs.

I couldn't find any instances of 'varbinary' in any of the *.install files either. This is most curious.

moonray’s picture

Could it have anything to do with update_convert_table_utf8() in update.php or mysqlfix_convert_table_utf8() in mysqlfix.php?

dave reid’s picture

That looks like it. Seems they were switched to varbinary, but were supposed to be fixed back.

jhodgdon’s picture

Component: search.module » update system
Priority: Critical » Normal
Status: Postponed (maintainer needs more info) » Active

So it looks like this is a bug in the update system for Drupal 5.x, not the search module. Is it still unfixed? Last comment here was more than a year ago...

jhodgdon’s picture

Component: update system » ajax system
Status: Active » Closed (won't fix)

7.0 is out tomorrow, 5.x is obsolete, won't fix, sorry.