|  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: -
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:
Status: Open Package: MySQLi related
PHP Version: 5.6.3 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jan 18 00:01:23 2020 UTC