Comment 4 for bug 408718

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The POTemplate and POFile are fixed and known when the query is constructed, so we can strip those out of the query:

SELECT
    POMsgId.msgid AS msgid,
    POMsgID_Plural.msgid AS msgid_plural,
    context,
    date_reviewed,
    is_current,
    is_imported,
    pt0.translation AS translation0,
    pt1.translation AS translation1,
    pt2.translation AS translation2,
    pt3.translation AS translation3,
    pt4.translation AS translation4,
    pt5.translation AS translation5
FROM POTMsgSet
JOIN TranslationTemplateItem ON
    TranslationTemplateItem.potmsgset = POTMsgSet.id AND
    TranslationTemplateItem.potemplate = %(potemplate)s
JOIN TranslationMessage ON
    POTMsgSet.id=TranslationMessage.potmsgset AND
    (TranslationMessage.potemplate = %(potemplate)s OR
     TranslationMessage.potemplate IS NULL) AND
    TranslationMessage.language = %(language)s AND
    TranslationMessage.variant IS NOT DISTINCT FROM %(variant)s
LEFT OUTER JOIN POTranslation pt0 ON pt0.id = TranslationMessage.msgstr0
LEFT OUTER JOIN POTranslation pt1 ON pt1.id = TranslationMessage.msgstr1
LEFT OUTER JOIN POTranslation pt2 ON pt2.id = TranslationMessage.msgstr2
LEFT OUTER JOIN POTranslation pt3 ON pt3.id = TranslationMessage.msgstr3
LEFT OUTER JOIN POTranslation pt4 ON pt4.id = TranslationMessage.msgstr4
LEFT OUTER JOIN POTranslation pt5 ON pt5.id = TranslationMessage.msgstr5
JOIN POMsgID ON
    POMsgID.id=POTMsgSet.msgid_singular
LEFT OUTER JOIN POMsgID AS POMsgID_Plural ON
    POMsgID_Plural.id=POTMsgSet.msgid_plural
WHERE (is_current IS TRUE OR is_imported IS TRUE)
ORDER BY
    TranslationTemplateItem.sequence,
    TranslationMessage.potemplate NULLS LAST