<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    waterye

    行列互換

    舊系統中的一條sql在某些情況下無法工作(反應超慢), 此sql是使用關聯進行行列互換, 從執行計劃和重建索引都查不出原因所在, 10G已經對sql不挑剔了, 暈啊(周五晚上的時間就這樣浪費掉)
     1select table2.id, 
     2       NVL(t1.count0as count1, 
     3       NVL(t2.count0as count2, 
     4       NVL(t3.count0as count3, 
     5       NVL(t4.count0as count4
     6 from table1 t1, table1 t2, table1 t3, table1 t4, table2 
     7 where t1.shop_id = ? and t1.type = 'a'
     8   and t2.shop_id = ? and t2.type = 'b'
     9   and t3.shop_id = ? and t3.type = 'c'
    10   and t4.shop_id = ? and t4.type = 'd'
    11   and table2.id = t1.id
    12   and table2.id = t2.id
    13   and table2.id = t3.id
    14   and table2.id = t4.id
    15 order by table2.code
    shop_id = 1386時很快(0.3s), shop_id = 1404時超慢(15s以上), 時間是在pl/sql developer執行時計算的, 不知是否oracle的bug

    只能對sql進行優化, 但一時不知如何解決(本人較笨), 只有發揮copy paste的能力(找google), http://www.oracle.com.cn/viewthread.php?tid=65638
    select t1.id, 
           
    sum(decode(t1.type, 'a'count0)) count1, 
           
    sum(decode(t1.type, 'b'count0)) count2,
           
    sum(decode(t1.type, 'c'count0)) count3,
           
    sum(decode(t1.type, 'd'count0)) count4
      
    from table1 t1, table2 t2
     
    where t1.id = t2.id
       
    and t1.shop_id = ?
     
    group by t1.id
     
    order by max(t2.code)

    執行時間0.17s(有點興奮, 程序員只有這點好處)

    還有通過SP進行行列互換的, 可到itpub上找找

    posted on 2005-12-17 01:32 waterye 閱讀(865) 評論(0)  編輯  收藏 所屬分類: oracle

    主站蜘蛛池模板: 亚洲精品无码久久久久去q| 亚洲av手机在线观看| 亚洲国产精品国自产电影| 最近免费字幕中文大全| 亚洲乱码中文字幕久久孕妇黑人 | 精品亚洲成在人线AV无码| 久久综合给合久久国产免费| 亚洲福利在线观看| 一级毛片在线免费看| 亚洲第一香蕉视频| 日韩吃奶摸下AA片免费观看| 亚洲人成小说网站色| 日韩高清在线免费看| 美女扒开屁股让男人桶爽免费| 国产一级特黄高清免费大片| 久久青草免费91线频观看站街| 亚洲无线观看国产精品| 久久久久免费看黄a级试看| 亚洲网站视频在线观看| 手机在线看永久av片免费| 国产精品自拍亚洲| 亚洲精品无码午夜福利中文字幕 | 免费国产成人α片| 亚洲第一页在线视频| 成人男女网18免费视频| 四虎影视永久在线精品免费| 日本红怡院亚洲红怡院最新| 久视频精品免费观看99| 国产精品无码亚洲精品2021 | 亚洲精品高清国产麻豆专区| 无码人妻久久一区二区三区免费丨| 亚洲av成人一区二区三区在线播放| 亚洲日本一区二区一本一道| 午夜精品一区二区三区免费视频| 亚洲人成网站看在线播放| 亚洲国产精品嫩草影院久久| 一级毛片在线免费观看| 精品在线观看免费| 久久精品九九亚洲精品| 国产在线98福利播放视频免费| 久久精品免费视频观看|