title: select with subquery takes about 1min in sqlite and < 1s in SQL Server
body: <p>I already looked up many posts about this problem (subqueries being very slow in sqlite). but I'm not really good with sql and i don't know what i can do.</p>
  
  <p>i have this query:</p>
  
  <pre><code>SELECT * FROM data d WHERE d.category = 3 AND 
  (SELECT COUNT(id) FROM data_tag WHERE data = d.id AND (tag = 2136 OR tag = 8)) &gt;= 2 
  ORDER BY id ASC
  </code></pre>
  
  <p>i have 3 tables 
  data,tag and data_tag (n-m of data and tag)
  every data has n tags and in this query i search datas by tags (2 tags, both must be in data)</p>
  
  <p>i switched my database from SQL Server to sqlite and besides this query everything works fine.
  in SQL Server this one took less then 1 sec to execute and in sqlite it takes about 1min.
  plz give me some tips.</p>