select t.unid, t.property, t.value from(
select rownum as unid,SUM_MONTH,'GRID_ID' as property,GRID_ID as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'STAY_TYPE' as property,STAY_TYPE as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'USER_CNT' as property,USER_CNT as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'AGE_LEVEL' as property,AGE_LEVEL as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'GENDER' as property,GENDER as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'FEE_LEVEL' as property,FEE_LEVEL as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'COMMUNITY_ID' as property,COMMUNITY_ID as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'STREET_ID' as property,STREET_ID as value from residents_portrait_character union all
select rownum as unid,SUM_MONTH,'COUNTY_ID' as property,COUNTY_ID as value from residents_portrait_character
) t where t.SUM_MONTH = 201812
order by UNID,case property
when 'GRID_ID' then 1
when 'STAY_TYPE' then 2
when 'USER_CNT' then 3
when 'AGE_LEVEL' then 4
when 'GENDER' then 5
when 'FEE_LEVEL' then 6
when 'COMMUNITY_ID' then 7
when 'STREET_ID' then 8
when 'COUNTY_ID' then 9
END;
對SUM_MONTH建了普通索引還是慢那,540萬條資料,查了半小時
uj5u.com熱心網友回復:
SUM_MONTH = 201812的資料有540萬?uj5u.com熱心網友回復:
估計是union all全部資料才過濾201812,這種應該先過濾201812再合并資料,可以看下執行計劃謂詞201812是否有推進內斂視圖uj5u.com熱心網友回復:
2018-12月的,橫表60萬行,轉換成縱表540行轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/54022.html
標籤:開發
下一篇:關于如何轉換欄位問題
