simple trick, big increase in performance

droplet - November 3, 2009 - 22:14
Project:Localization server
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

When we import po files, it compare each strings in database. Strings store in database as TEXT, it cannot add indexs. so I added a hashkey field to database.

My test:
importing a drupal.po

Before:
65s

After:
6s

(l10n_server status: 5xxxx strings to translate)

here what I do:

1. add HashKey field [type: binary(32)] to l10n_community_string table [md5(value)] , add index to this field (important)
2. change following code:

<?php
// l10n_server\l10n_community\import.inc
   
if ($sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE BINARY value = '%s' AND context = '%s'", $value['msgid'], $value['msgctxt']))) {
?>

to

<?php
//  l10n_server\l10n_community\import.inc
 
$value['msgid'] = md5($value['msgid']);
  if (
$sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE HashKey = '%s' AND context = '%s'", $value['msgid'], $value['msgctxt']))) {
?>

it can apply to l10n_server sub-modules / locales modules if no side effect.

Need your comment.

Thanks.

(** Is there anyway I can get all l.d.o server Strings ? I need some large data to do test and special usage)

 
 

Drupal is a registered trademark of Dries Buytaert.