On Sat, 27 Apr 2013 07:06:31 -0700 (PDT)
Gianni Sassanelli <gs4n...@gmail.com> wrote:

> I have a slow performance if i USE the view but only when i use it
> from ANDROID

I don't know if it will help, but the following query should produce
the same results and might execute faster:

SELECT id_arbox,
       cdstagioni,
       cdlinee,
       cdbox,
       ncolori,       
       radiato,       
       totalepz,
       cdar,
       cdtessuti,
       cdcart,
       case Q when 1 then cdcolori 
                     else '-' 
              end as 'cdcolori'
       case Q when 1 then C.descrizione 
                     else 'ASSORTITO' 
              end as 'colori_descrizione'
FROM (
        select id_arbox        As id_arbox,
               cdstagioni      As cdstagioni,
               cdlinee         As cdlinee,
               cdbox           As cdbox,
               nColori         As ncolori,       
               radiato         As radiato,       
               SUM(QTotRiga)   As totalepz,
               cdar            As cdar,
               cdarmp          As cdtessuti,
               cdcart          As cdcart,
               MIN(cdcolori)   As cdcolori,       
               COUNT(cdcolori) As Q
        from arbox
        group by
               id_arbox,
               cdstagioni,
               cdlinee,
               cdbox,
               nColori,       
               radiato,       
               cdar,
               cdarmp,
               cdcart          
) as AB
JOIN Colori As C ON C.CdColori = AB.CdColori
ORDER BY 
      AB.cdstagioni,
      AB.cdar,      
      AB.cdarmp,      
      AB.cdbox,      
      AB.cdcolori;

I cannot explain the behavior you reported.  By mentioning the main
table only once, though, you may make it easier for the query optimizer
to do its job.  

HTH.  

--jkl

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to