//putenv("FET_BUF_SIZE=32767") ;

  putenv("FET_BUF_SIZE=4096") ;

  echo getenv("FET_BUF_SIZE") ;



  $SQL = "select stkday,groupid,seqno,stkid,buysell,warid,to_time, " .

         "currenttime,coltype,order_type ".

         "from hisorderdeal " ;

  $oRs = ifx_prepare($SQL,$DbObj);

  ifx_do($oRs);

  $arrayofhedge = ifx_fetch_row($oRs,"next");

  $icnt = 0 ;

  while(is_array($arrayofhedge))

  {

     echo $icnt . "
\n" ;

     $arrayofhedge = ifx_fetch_row($oRs,"next");

     $icnt = $icnt + 1 ;

  }

  ifx_free_result($oRs);



  netscb type   thread name    sid   fd poll    reads   writes q-nrm q-pvt q-exp

5e3568a8 soctcp soctcppoll       3    0    6      267        0  0/ 0  0/ 0  0/ 0

5e2fee10 soctcp soctcppoll       4    0    7     2093        0  0/ 0  0/ 0  0/ 0



用 32767 跟 用 4096 的差別.......  使用 php 語法 putenv 可以設定 環境變數:  FET_BUF_SIZE

跟  esql/c 使用 FetBufSize 一樣的效果!!!



FetBufSize 是當你跟 Informix open cursor 時 , 告訴 Informix 你用多大的 Buffer 來容納

這個 cursor 的資料 , Informix 用這個值大小來判斷,每個網路封包含多大資料量會比較節省網路傳輸量!!

sample 如下 :



EXEC SQL include sqlhdr;  //FetBufSize 變數定義在此



main()

{

   FetBufSize=32767 ; //cursor buffer size , 最大 32767 bytes , default = 4000 !!



   EXEC SQL declare cursorx cursor for

      select stkday,groupid,seqno,stkid,buysell,warid,to_time,

             currenttime,coltype,order_type

            from hisorderdeal ;

   EXEC SQL  open  cursorx  ;

   while(1)

   {

      EXEC SQL fetch cursorx into

           $stkday,$groupid,$seqno,$stkid,$buysell,$warid,$to_time,

           $currenttime,$coltype,$order_type ;

      if(sqlca.sqlcode !=0)

         break ;

   }//while

}//main





以上片段,當有 FetBufSize=32767 ;  時 , 跟沒有此行的差別,用 onstat -g ntu(socket 封包的數目資訊) 可以明顯看出:



  netscb type   thread name    sid   fd poll    reads   writes q-nrm q-pvt q-exp

5e2bae00 soctcp soctcppoll       6    0    9      267        0  0/ 0  0/ 0  0/ 0

5e356e10 soctcp soctcppoll       5    0    8     2093        0  0/ 0  0/ 0  0/ 0



FetBufSize=32767 時 , Informix 對此程式封包傳了 267 次, FetBufSize 是default 的 4000時,Informix 對此程式封包傳了 2093 次

 

arrow
arrow
    全站熱搜

    hedgezzz 發表在 痞客邦 留言(0) 人氣()