Re: A discussion about unixODBC programming model
Nick Gorham <[email protected]> Mon, 24 Nov 2014 09:24:03 +0000
| Newsgroups | gmane.comp.db.unixodbc.devel |
|---|---|
| Message-ID | <[email protected]> |
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
[email protected]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev