Select com pivot lento...
Oi Pessoal!
Estou tendo problemas de performance com o select abaixo:
Ele retorna aproximadamente 740938 linhas. Eu acredito que o problema esteja no subselect.
Como posso melhorar este select?
Obrigado!
SELECT timesec,
(SELECT a.value FROM historicotags a WHERE a.idtag = 663 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '663' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 724 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '724' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 685 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '685' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 684 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '684' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 664 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '664' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 922 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '922' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 923 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '923' ,
(SELECT a.value FROM historicotags a WHERE a.idtag = 924 AND a.timesec <=
h.timesec ORDER BY a.timesec desc LIMIT 1) as '924'
FROM historicoTags h WHERE timesec between 1295488800 AND 1295551799 GROUP
BY timesec;
Subject
Views
Written By
Posted
Select com pivot lento...
3844
January 26, 2011 10:15AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.