[unixODBC-dev] A discussion about unixODBC programming model

xiaonan xn212516 at 163.com
Mon Nov 24 09:49:48 GMT 2014


Hi Nick,

Got it, thanks!

Best Regards
Nan Xiao
At 2014-11-24 17:24:03, "Nick Gorham" <nick at lurcher.org> wrote:
>On 24/11/14 08:24, xiaonan wrote:
>>
>> Hi Nick,
>>
>>
>> 	I have do the performance test to check which method is the best one: The process has 20 threads, and every thread insert 5000 records into MySQL database.
>>
>>
>> 	There are 3 kinds of connection model:
>>
>>
>> 	(1) normal case:
>> 	The execution flow of every thread likes this:
>> 	
>> 	for ()
>> 	{
>> 		Connect database;
>> 		Execute SQL statement;
>> 		Disconnect database;
>> 	}
>> 	
>> 	After testing 5 times, the average time is 16 seconds.
>> 	
>> 	(2) Shared connection case:
>> 	In this model, all the 20 threads share a common connection. And the execution flow of every thread likes this:
>> 	
>> 	for ()
>> 	{
>> 		Execute SQL statement;
>> 	}
>> 	
>> 	After testing 5 times, the average time is 19 seconds.
>> 	
>> 	(3) Excluded connection case:
>> 	In this model, all the 20 threads have a exclusive connection. And the execution flow of every thread likes this:
>> 	
>> 	Connect database;
>> 	for ()
>> 	{
>> 		Execute SQL statement;
>> 	}
>> 	Disconnect database;
>> 	
>> 	After testing 5 times, the average time is 5 seconds.
>> 	
>> 	So after testing, the third method is more efficient than the other two methods.
>> 	
>> 	The attachment are the source code. If you have interest, you can read them, thanks!:-)
>
>Yep, there are no hard and fast rules, it all depends on the driver and 
>network protocol if any.
>
>-- 
>Nick
>_______________________________________________
>unixODBC-dev mailing list
>unixODBC-dev at mailman.unixodbc.org
>http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev


More information about the unixODBC-dev mailing list