i got a system that need to connect 2 DB , one is mysql , another is ODBC.
when i retrive data from ODBC, it will turn to very slow. And i feel trouble each time retrive data from ODBC, b'cos need to connect again, then close
any method can making faster ? thank's for any reply

$dw = odbc_connect("dw","dd","dd")

$query = "SELECT * FROM DW.dw_emp WHERE DEPT_ID >= '$dept_From' and DEPT_ID <= '$dept_To' ";

$result = odbc_exec($dw, $query);
while($row = odbc_fetch_array($result))

odbc_close($dw);

    Hi,

    if you use odbc_pconnect then the connection remains open in the background and will be used again when you try to connect to the database again with the same credentials.

    In some cases you might want to use odbc_free_result at the end of your script to make sure that all resources will be freed when the script ends. If auto_commit is disabled and you call odbc_free_result, all transactions will be rolled back.

    A reason for the odbc connection being slow can be that there are some indexes missing on the table, maybe on e.g. DEPT_ID. Also you might try only to fetch the fields you only need instead of SELECT *.

      I have try the method u give me, but still cannot solve the problem of slow.

      i use ODBC link with sybase DB, when connect the DB was quite slow...then i change to ODBC link with mySql, it was quite fast as same as direct connect.

      i dunno whether is sybase DB problem or coding structure problem.

      In a page, i select more than 10 table and more than 1000 record.

      thank ur reply

        Hi,

        php supports direct connection to Sybase, too. You might need to rebuild php to enable Sybase support.

        One of the most important issues with speed could be missing indexes. Did you check that you set up all your indexes correctly on the tables ?

          Write a Reply...