[unixODBC-dev] A discussion about unixODBC programming model

Nick Gorham nick at lurcher.org
Mon Nov 24 09:24:03 GMT 2014


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


More information about the unixODBC-dev mailing list