mysql_use_result issue: useless iterating over unused results
Hello list, I am having this issue with mysql_use_result: it seems it will iterate over all unused results if I call 'mysql_free_result'. The following code illustrates this: mysql_query(mysql,SELECT * FROM a_very_large_table); res = mysql_use_result(mysql); i = 0; while (row = mysql_fetch_row(res)) { fprintf(stderr,%d,%d\n, row[0], row[1]); if (++i 5) break; } fprintf(stderr,freeing...\n); mysql_free_result(res); /* wait wait wait wait wait wait wait wait ... */ With 'mysql_store_results', the code would run out of memory, because the table is very large (20m rows). But this version will run up to 2 minutes, taking all CPU cycles with it, just freeing the result. Is this normal behaviour or can I change something for the better? I am using mysql 4.0.22 client and server on Linux 2.6. Thanks! Renald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
mysql_use_result issue: useless iterating over unused results
Hello list, I am having this issue with mysql_use_result: it seems it will iterate over all unused results if I call 'mysql_free_result'. The following code illustrates this: mysql_query(mysql,SELECT * FROM a_very_large_table); res = mysql_use_result(mysql); i = 0; while (row = mysql_fetch_row(res)) { fprintf(stderr,%d,%d\n, row[0], row[1]); if (++i 5) break; } fprintf(stderr,freeing...\n); mysql_free_result(res); /* wait wait wait wait wait wait wait wait ... */ With 'mysql_store_results', the code would run out of memory, because the table is very large (20m rows). But this version will run up to 2 minutes, taking all CPU cycles with it, just freeing the result. Is this normal behaviour or can I change something for the better? I am using mysql 4.0.22 client and server on Linux 2.6. Thanks! Renald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql_use_result issue: useless iterating over unused results
Yup. This is a normal behaviour. mysql_free_result() will result in bringing each unasked rows to the client and freeing it up row by row. BTW, why do you need to do - select * from Karam --- Renald Buter [EMAIL PROTECTED] wrote: Hello list, I am having this issue with mysql_use_result: it seems it will iterate over all unused results if I call 'mysql_free_result'. The following code illustrates this: mysql_query(mysql,SELECT * FROM a_very_large_table); res = mysql_use_result(mysql); i = 0; while (row = mysql_fetch_row(res)) { fprintf(stderr,%d,%d\n, row[0], row[1]); if (++i 5) break; } fprintf(stderr,freeing...\n); mysql_free_result(res); /* wait wait wait wait wait wait wait wait ... */ With 'mysql_store_results', the code would run out of memory, because the table is very large (20m rows). But this version will run up to 2 minutes, taking all CPU cycles with it, just freeing the result. Is this normal behaviour or can I change something for the better? I am using mysql 4.0.22 client and server on Linux 2.6. Thanks! Renald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql_use_result issue: useless iterating over unused results
On 01:55 Tue 11 Jan , Karam Chand wrote: Yup. This is a normal behaviour. mysql_free_result() will result in bringing each unasked rows to the client and freeing it up row by row. This sounds to me as a useless feature. What could be the reason for such wasting behaviour? BTW, why do you need to do - select * from I need to visit every row. Originally, this came up when debugging my code, and since then I added a LIMIT statement when doing so. But it still find these kinds of things annoying and unsatisfiying from an engineering point of view --- and I was just curious if it was *me* who did something wrong. But thanks for the answer! Regards, Renald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql_use_result issue: useless iterating over unused results
I am not sure why they are doing it. You need to hack the protocol to understand it. Maybe some MySQL/network GURU will be able to help yuo. Regards, Karam --- Renald Buter [EMAIL PROTECTED] wrote: On 01:55 Tue 11 Jan , Karam Chand wrote: Yup. This is a normal behaviour. mysql_free_result() will result in bringing each unasked rows to the client and freeing it up row by row. This sounds to me as a useless feature. What could be the reason for such wasting behaviour? BTW, why do you need to do - select * from I need to visit every row. Originally, this came up when debugging my code, and since then I added a LIMIT statement when doing so. But it still find these kinds of things annoying and unsatisfiying from an engineering point of view --- and I was just curious if it was *me* who did something wrong. But thanks for the answer! Regards, Renald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] __ Do you Yahoo!? All your favorites on one personal page Try My Yahoo! http://my.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]