|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68548 slow calls to mysqli_fetch_field when using MYSQLI_STORE_RESULT_COPY_DATA
Submitted: 2014-12-05 04:15 UTC Modified: 2020-03-22 04:22 UTC
Avg. Score:2.5 ± 1.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: ryan dot brothers at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: MySQLi related
PHP Version: 5.6.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ryan dot brothers at gmail dot com
New email:
PHP Version: OS:


 [2014-12-05 04:15 UTC] ryan dot brothers at gmail dot com
I am seeing an issue where calls to mysqli_fetch_field() are very slow when using MYSQLI_STORE_RESULT_COPY_DATA.

In the below example, the call to fetch_field takes 5 seconds to run.

If the below is changed to call store_result() without MYSQLI_STORE_RESULT_COPY_DATA, then the call to fetch_field takes 0.006 seconds to run.

Is there a way that the time to call fetch_field could be improved when using MYSQLI_STORE_RESULT_COPY_DATA?

I have placed SQL to create a test table of 100,000 rows at

Thanks for your help.

Test script:
$mysqli = new mysqli('localhost', 'test', 'test', 'test');

$mysqli->real_query("SELECT * FROM a");

$result = $mysqli->store_result(MYSQLI_STORE_RESULT_COPY_DATA);

$start = microtime(true);

$field = $result->fetch_field();

echo microtime(true) - $start."\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-31 20:38 UTC] notvalid at gmail dot com
Also of note, CPU utilization is maxed out during the delay in returning the list of fields. On a result set with over 1m rows, MYSQLI_STORE_RESULT_COPY_DATA results in over a 30 minute call to fetch_fields() while disabling MYSQLI_STORE_RESULT_COPY_DATA returns data from fetch_fields() almost immediately.
 [2019-02-11 02:32 UTC] ryan dot brothers at gmail dot com
I just submitted bug 77597, where now in PHP 7.3.2, calling mysqli_fetch_field hangs the script completely.
 [2020-03-09 17:56 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-03-09 17:56 UTC]
The other bug has been fixed, so I wonder whether that resolved
this issue as well.
 [2020-03-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 00:01:24 2020 UTC