Skip to content

Instantly share code, notes, and snippets.

@souen
Created May 15, 2012 18:21
Show Gist options
  • Save souen/2703937 to your computer and use it in GitHub Desktop.
Save souen/2703937 to your computer and use it in GitHub Desktop.
Slow queries sur les section sans contenus
# Requête 1: sélectionne un contentmodel lié à la rubrique *100126* (qui n'en contient aucun)
# Prend 15-30s
SELECT "libe_contentmodel"."id","libe_contentmodel"."child_type"
FROM "libe_contentmodel"
INNER JOIN "libe_contenttosection"
ON ("libe_contentmodel"."id" = "libe_contenttosection"."content_model_id")
WHERE ("libe_contenttosection"."section_id" = 100126 AND "libe_contentmodel"."workflow_state" = 20 )
ORDER BY "libe_contentmodel"."computed_ponderation" DESC, "libe_contentmodel"."updating_date" DESC LIMIT 1
# Requête 2: remonte un contentmodel lié à la rubrique *100132* (qui en contient un)
# Est rapide!
SELECT "libe_contentmodel"."id", "libe_contentmodel"."child_type"
FROM "libe_contentmodel"
INNER JOIN "libe_contenttosection"
ON ("libe_contentmodel"."id" = "libe_contenttosection"."content_model_id")
WHERE ("libe_contenttosection"."section_id" = 100132 AND "libe_contentmodel"."workflow_state" = 20 )
ORDER BY "libe_contentmodel"."computed_ponderation" DESC, "libe_contentmodel"."updating_date" DESC LIMIT 1
# Why ??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment