At 18:06 +0200 1/8/03, Vladimir Zheleznyak wrote:
>Subject: delay on executing mysql_free_result with underfetched query
>If to execute mysql_use_result on the query that returns large amount of
>records and then
>execute mysql_free_result - execution the last function take time equal to
>fetch all data to client.
>Is it possible to avoid this delay?
No. The reason this happens is due to the way that mysql_free_result()
is implemented, to avoid "commands out of sync" errors. In the old
days, if you used mysql_use_result() and then didn't fetch all the
rows, calling mysql_free_result() released the result set on the client,
but the server still had rows left to send. The next query would fail
with an out-of-sync error.
Now, mysql_free_result() automatically fetches and discards any yet-unfetched
rows, which avoids that problem.
It'd be nice were it possible to tell the server itself to discard the
rows, but it doesn't work that way. Maybe you can use LIMIT to generate just
the initial part of the result, if you suspect that you're not going to
need it all.
>Synopsis: Delays on breaking fetch
>Originator: Vladimir Zheleznyak
>Organization: Core Lab
>MySQL support: none
>Category: mysql client, C
>Environment: Celeron 800, RAM 256 MB, localhost
>Compiler: VC++ 6.0