Jeremy Zawodny wrote:
> 
> > >   SELECT COUNT(*) FROM foo WHERE ...
> > >
> > How can I get this to work with a GROUP BY?
> 
> Can you post the query along with the output of EXPLAIN <query> so we
> can get a good idea what's going on?

Query:

SELECT
  documents.document_id
 FROM
  documents,
  dictionary AS d0,
  dictionary AS d1,
  textindex AS i0, 
  textindex AS i1
 WHERE
  i0.document_id = documents.document_id AND
  d0.word_id=i1.prev_word_id AND
  d1.word_id=i1.word_id AND
  i1.prev_textindex_id = i0.id AND
  d0.word='windows' AND
  d1.word='2000'
 GROUP BY
  documents.document_id;

explain:

table     type   possible_keys     key     len ref                  rows Extra         
          
d0        const  PRIMARY,word      word    256 const                1    Using 
temporary        
d1        const  PRIMARY,word      word    256 const                1                  
        
i1        ref    word_id,          word_id 6   const,const          13                 
         
                 prev_textindex_id 
i0        eq_ref PRIMARY           PRI     4   i1.prev_textindex_id 1                  
        
documents eq_ref PRIMARY           PRI     3   i0.document_id       1    where used; 
                                                                         Using index


Any ideas on how to speed this up also appreciated :-)

cheers,

Chris

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to