Hi Butch Bean, What if you use a temporary table .
Issue the following queries. Create temporary table tmptable as select sent_id,count(*) cnt from tbl_sent group by sent_id; Select sum(if(sent_id < idvar,1,0)) as lessthan, sum(if(sent_id >idvar,1,0)) as greaterthan from tmptable; Let us know if it improves the performance? Anvar. At 11:43 AM 06/02/2002 -0500, you wrote: >I have a table with 2.9 mil records which represents 197k sentences stored >vertically. I do this because I need to know information about each word >and its relationship to other tables. > >I want to know how many words have a particular word-group ID before and a >particular word-group ID after the word ID I am looking for. All of the >fields shown are indexed integer fields. > >The examples below actually work fine but Word ID #8 happens to be a popular >word ('the' 216,000) and this query takes 1 min 15 sec to run. When the >Word ID I am looking for is not so popular it executes in 0.05 - 5.0 >seconds. Basically, 90% of the time its OK but 10% of the time is taking >longer than the 90%. > >One of the things I noticed with the server is that the CPU and disk access >is virtually nothing while these joins are running. Other parts of my >program can take the CPU near 100% when running multiple copies but when any >of those copies get to this Inner Join it is slow and is tagged as a MySQL >Slow query. > >Are there settings I should be making on the Server? > >Is there a better way or method to make a query like this go faster? > >Thanks >Butch Bean --------------------------------------------------------------------- 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