diff --git includes/locale.inc includes/locale.inc
index 578b1b3..e60b8dd 100644
--- includes/locale.inc
+++ includes/locale.inc
@@ -983,7 +983,11 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL
  *   The string ID of the existing string modified or the new string added.
  */
 function _locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid = 0, $plural = 0) {
-  $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = :context AND textgroup = :textgroup", array(':source' => $source, ':context' => $context, ':textgroup' => $textgroup))->fetchField();
+  $hashkey = drupal_hash_base64($source . $context);
+  $lid = db_query("SELECT lid FROM {locales_source} WHERE hashkey = :hashkey AND textgroup = :textgroup", array(
+    ':hashkey' => $hashkey,
+    ':textgroup' => $textgroup
+  ))->fetchField();
 
   if (!empty($translation)) {
     // Skip this string unless it passes a check for dangerous code.
@@ -1041,6 +1045,7 @@ function _locale_import_one_string_db(&$report, $langcode, $context, $source, $t
           'source' => $source,
           'context' => (string) $context,
           'textgroup' => $textgroup,
+          'hashkey' => $hashkey,
         ))
         ->execute();
 
@@ -1413,7 +1418,8 @@ function _locale_parse_js_file($filepath) {
       // Remove the quotes and string concatenations from the string.
       $string = implode('', preg_split('~(?<!\\\\)[\'"]\s*\+\s*[\'"]~s', substr($string, 1, -1)));
 
-      $source = db_query("SELECT lid, location FROM {locales_source} WHERE source = :source AND textgroup = 'default'", array(':source' => $string))->fetchObject();
+      $hashkey = drupal_hash_base64($string);
+      $source = db_query("SELECT lid, location FROM {locales_source} WHERE hashkey = :hashkey AND textgroup = 'default'", array(':hashkey' => $hashkey))->fetchObject();
       if ($source) {
         // We already have this source string and now have to add the location
         // to the location column, if this file is not yet present in there.
@@ -1440,6 +1446,7 @@ function _locale_parse_js_file($filepath) {
             'source' => $string,
             'context' => '',
             'textgroup' => 'default',
+            'hashkey' => $hashkey,
           ))
           ->execute();
       }
diff --git modules/locale/locale.install modules/locale/locale.install
index a144813..a969161 100644
--- modules/locale/locale.install
+++ modules/locale/locale.install
@@ -204,10 +204,17 @@ function locale_schema() {
         'default' => 'none',
         'description' => 'Version of Drupal, where the string was last used (for locales optimization).',
       ),
+      'hashkey' => array(
+        'description' => 'MD5 hash of the concatenation of context and string, used for quick lookups.',
+        'type' => 'char',
+        'length' => 64,
+        'not null' => TRUE,
+      ),
     ),
     'primary key' => array('lid'),
     'indexes' => array(
       'source_context' => array(array('source', 30), 'context'),
+      'hashkey' => array('hashkey'),
     ),
   );
 
diff --git modules/locale/locale.module modules/locale/locale.module
index 9505f72..202678b 100644
--- modules/locale/locale.module
+++ modules/locale/locale.module
@@ -651,10 +651,10 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
   if (!isset($locale_t[$langcode][$context][$string])) {
 
     // We do not have this translation cached, so get it from the DB.
-    $translation = db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'", array(
+    $hashkey = drupal_hash_base64($string . (string) $context);
+    $translation = db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.hashkey = :hashkey AND s.textgroup = 'default'", array(
       ':language' => $langcode,
-      ':source' => $string,
-      ':context' => (string) $context,
+      ':hashkey' => $hashkey,
     ))->fetchObject();
     if ($translation) {
       // We have the source string at least.
@@ -681,6 +681,7 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
           'context' => (string) $context,
           'textgroup' => 'default',
           'version' => VERSION,
+          'hashkey' => $hashkey,
         ))
         ->execute();
       $locale_t[$langcode][$context][$string] = TRUE;
