optimizer of informix behavior question
Posted in 2011
Topics: Performance & Tuning, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
Dear All... I've developed esql/c in Linux accessing IDS 11.5 for years , As I remembered the following cursor will do only one time optimization , in the prepare statement ,after that , IDS won't do any optimization during cursor open and cursor close inside while loop , that means , it should be quite good way to get performance : sprintf(strsql,"%s", select id,passwd from tablex where id = ? ) ; EXEC SQL prepare idx from $strsql ; EXEC SQL declare cursorx cursor for idx ; While(1) { DoGetId(varx) ; EXEC SQL open cursorx using $varx ; While(1) { EXEC SQL fetch cursorx into $id,$passwd ; If(sqlca.sqlcode !=0) Break ; Dosomething() ; }//while EXEC SQL close cursorx ; } EXEC SQL free cursorx ; EXEC SQL free idx ; And then , I'd like to test C# ... My friend give me the following sample source of C# ... I'd like to know , if this C# source do optimized once only ,just like my esql/c source ? string sqlx = "select id,ptrade, transdate from quote where transdate > ? "; dbcmd.CommandText = sqlx; dbcmd.Parameters.Clear(); dbcmd.Parameters.Add("@param1", OleDbType.DBTimeStamp); OleDbDataReader dbread= null; dbcmd.Parameters["@param1"].Value = dttime; while (true) { dbcmd.Parameters["@param1"].Value = dttime; dbread = dbcmd.ExecuteReader(); while (dbread.Read()) { if (!dbread.HasRows) break; Console.WriteLine("{0} {1}", dbread["id"].ToString(), dbread["ptrade"].ToString()); dttime = DateTime.Parse(dbread["transdate"].ToString()); } dbread.Close(); } I am not familiar with C# ... Any comment,suggestion are welcome,thanks !!
Correct. Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Tue, Dec 27, 2011 at 9:45 PM, MARS CHEN <hedgezzz@yahoo.com.tw> wrote: > Dear All... > > I've developed esql/c in Linux accessing IDS 11.5 for years , > As I remembered the following cursor will do only one time optimization , > in the prepare statement ,after that , IDS won't do any optimization > during cursor open and cursor close inside while loop , > that means , it should be quite good way to get performance : > > sprintf(strsql,"%s", > select id,passwd from tablex where id = ? ) ; > EXEC SQL prepare idx from $strsql ; > EXEC SQL declare cursorx cursor for idx ; > While(1) > { > > DoGetId(varx) ; > > EXEC SQL open cursorx using $varx ; > > While(1) > > { > > EXEC SQL fetch cursorx into $id,$passwd ; > > If(sqlca.sqlcode !=0) > > Break ; > > Dosomething() ; > > }//while > > EXEC SQL close cursorx ; > } > EXEC SQL free cursorx ; > EXEC SQL free idx ; > > And then , I'd like to test C# ... My friend give me the following sample > source of C# ... I'd like to know , if this C# source do optimized once > only > ,just like my esql/c source ? > > string sqlx = "select id,ptrade, transdate from quote where transdate > ? > "; > dbcmd.CommandText = sqlx; > dbcmd.Parameters.Clear(); > dbcmd.Parameters.Add("@param1", OleDbType.DBTimeStamp); > OleDbDataReader dbread= null; > dbcmd.Parameters["@param1"].Value = dttime; > while (true) > { > > dbcmd.Parameters["@param1"].Value = dttime; > > dbread = dbcmd.ExecuteReader(); > > while (dbread.Read()) > > { > > if (!dbread.HasRows) > > break; > > Console.WriteLine("{0} {1}", dbread["id"].ToString(), > > dbread["ptrade"].ToString()); > > dttime = DateTime.Parse(dbread["transdate"].ToString()); > > } > > dbread.Close(); > } > > I am not familiar with C# ... Any comment,suggestion are welcome,thanks !! > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --14dae93405376daef704b51e0634