|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-09-22 14:27 UTC] phoeniks2k at mail dot ru
Description: ------------ If result set has clob\blob fields, retrieving data is VERY slow. Query "SELECT SQL_NO_CACHE id, xml_clob FROM some_table WHERE id = 1" executes 1000 times for about 0.4 seconds on my server; But this query rewriten with statement execs 20 time for 6(!) seconds!!! Every time i call: exec, store result, fetch, free_result P.S. SQL_NO_CACHE is used for clean noncached result times Expected result: ---------------- STMT performance higher then normal query performance PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 15:00:01 2025 UTC |
<?php function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((double)$usec + (double)$sec); } $host = 'localhost'; $login = 'parallax'; $password = 'parallax'; $db_name = 'parallax_kernel'; $link = mysqli_init(); mysqli_real_connect($link, $host, $login, $password, $db_name); $st = mysqli_prepare($link, "SELECT id, title, proto, lnk4, mdf, xml FROM objects_hier oh WHERE owner = ?"); $info = array(); $owner = 0; mysqli_stmt_bind_param($st, 'i', $owner); /*---------------------------------------------------------*/ $t = getmicrotime(); for ($owner = 0; $owner < 20; $owner++) { mysqli_stmt_execute($st); mysqli_stmt_bind_result($st, $info['id'], $info['title'], $info['proto'], $info['lnk4'], $info['mdf'], $info['xml']); while (mysqli_fetch($st)) { // some data manipulations that are equiv. those in query } mysqli_stmt_free_result($st); } echo (getmicrotime() - $t).'<br>'; /*--------------------------------------------------------*/ $t = getmicrotime(); for ($owner = 0; $owner < 20; $owner++) { $recordset = mysqli_query($link, "SELECT id, title, proto, lnk4, mdf, xml FROM objects_hier oh WHERE owner = $owner"); while ($row = mysqli_fetch_assoc($recordset)) { // some data manipulations that are equiv. those in stmt } mysqli_free_result($recordset); } echo (getmicrotime() - $t).'<br>'; ?>