Skip to content

Instantly share code, notes, and snippets.

@scottdriscoll
Created March 27, 2013 23:10
Show Gist options
  • Save scottdriscoll/5258979 to your computer and use it in GitHub Desktop.
Save scottdriscoll/5258979 to your computer and use it in GitHub Desktop.
slow query...
explain analyze SELECT
count(1) AS count
FROM
merlin.merlin_templates t
INNER JOIN merlin.merlin_keywords k ON t.id = k.merlin_template_id
WHERE
t.enabledstatus = 1
AND t.disabled = 0
AND k.keyword @@ to_tsquery('red|blue')
AND product_id = 1
@bstaz
Copy link

bstaz commented Mar 27, 2013

explain analyze SELECT 
  count(1) AS count 
FROM 
  merlin.merlin_templates t 
    INNER JOIN merlin.merlin_keywords k ON t.id = k.merlin_template_id,
  to_tsquery('red|blue') query
WHERE 
  t.enabledstatus = 1 
  AND t.disabled = 0 
  AND query @@ k.tsv_keyword
  AND product_id = 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment