Hi all,
  I have this query:
   
  select CATALOGUES.idcatalogue, CATALOGUES.type, PERSONS.surname, 
 max(HISTORY.startingfrom) as maxdate 
FROM PERSONS 
  INNER JOIN CATALOGUES 
                  ON CATALOGUES.idperson = PERSONS.idperson  
  INNER JOIN HISTORY 
                  ON HISTORY.idcatalogue = CATALOGUES.idcatalogue
WHERE CATALOGUES.active='y' 
group by  PERSON.surname, CATALOGUES.idcatalogue,  CATALOGUES.type
   
  with indexes on:
   
  PERSONS.surname
  PERSONS.idperson
  CATALOGUES.active
  CATALOGUES.idcatalogue
  CATALOGUES.type
  HISTORY.idcatalogue
  HISTORY.startingfrom
   
  Tables contains about:
   
  PERSONS 700000 records
  CATALOGUES 70 records
  HISTORY 4 million records
   
  My query is extremely slow (about 90 seconds).
  If I exclude the group by and the max functions, it is extremely fast.
  So problem should be in group by.
  How can I improve the performance?
   
  Thank you very much for your explanation.
   

       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to