Comment 4 for bug 734642

Robert Collins (lifeless) wrote :

using a regular join gets a 225 estimated cost and 300ms runtime:
SELECT DISTINCT ON (COALESCE(msgstr0, -1), COALESCE(msgstr1, -1), COALESCE(msgstr2, -1), COALESCE(msgstr3, -1), COALESCE(msgstr4, -1), COALESCE(msgstr5, -1)) TranslationMessage.id
     FROM TranslationMessage join (potmsgset JOIN TranslationTemplateItem ON TranslationTemplateItem.potmsgset = POTMsgSet.id
          JOIN SuggestivePOTemplate ON TranslationTemplateItem.potemplate = SuggestivePOTemplate.potemplate) on TranslationMessage.potmsgset=POTMsgSet.id
     WHERE (TranslationMessage.LANGUAGE IN (132))
       AND TranslationMessage.potmsgset <> 8171049
       AND msgid_singular = 347523
     ORDER BY COALESCE(msgstr0, -1), COALESCE(msgstr1, -1), COALESCE(msgstr2, -1), COALESCE(msgstr3, -1), COALESCE(msgstr4, -1), COALESCE(msgstr5, -1), date_created DESC LIMIT 2001;