scieloorg/SciELO-Manager — pull request #559 by gustavofonseca (2013-09-30 18:50:01+00:00)
Title: Ajustes no manager RegularPressReleaseCustomManager.by_journal_pid para realizar uma query mais eficiente ao BD

A query resultante deste ticket ficou assim:

```sql
SELECT "journalmanager_pressrelease"."id",
"journalmanager_pressrelease"."doi",
"journalmanager_regularpressrelease"."pressrelease_ptr_id",
"journalmanager_regularpressrelease"."issue_id"
FROM "journalmanager_regularpressrelease"
INNER JOIN "journalmanager_pressrelease"
ON ("journalmanager_regularpressrelease"."pressrelease_ptr_id" = "journalmanager_pressrelease"."id")
WHERE "journalmanager_regularpressrelease"."pressrelease_ptr_id" IN (
SELECT U0."pressrelease_ptr_id"
FROM "journalmanager_regularpressrelease" U0
INNER JOIN "journalmanager_issue" U1
ON (U0."issue_id" = U1."id")
WHERE U1."journal_id" IN (
SELECT U0."id"
FROM "journalmanager_journal" U0
WHERE (U0."print_issn" = '0034-8910' OR U0."eletronic_issn" = '0034-8910' )))
LIMIT 20;

```

O uso de subqueries e pré-carga das traduções fez com que o endpoint *pressreleases* melhorasse o desempenho em aproximadamente 50%, de acordo com medição tosca.