Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Connection takes 2 seconds - normal?


This question is answered. Helpful answers available: 0. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Nov 25, 2015 4:17 AM Last Post By: Andrea Kaiser
Andrea Kaiser

Posts: 63
Registered: 11/17/15
Connection takes 2 seconds - normal?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 25, 2015 3:29 AM
I'm using the following code to connect with FireDAC to MySQL 5.5.10:

    try
      (* Driver *)
      with FDPhysMySQLDriverLink do begin
        DriverID  := 'MySQL';
        VendorLib := 'C:\MySQL\Lib\libmysql.dll';
      end;
 
      (* Connection *)
      with FDConnection do begin
        DriverName  := 'MySQL';
        LoginPrompt := false;
        Params.DriverID := 'MySQL';
        Params.UserName := 'root';
        Params.Password := '';
        Params.Add('Server=localhost');
        Params.Add('Port=3306');
        Connected := true;                            <--- takes 2 seconds
      end;
    except
      on E:Exception do
        Connect := E.Message;
    end;


1. The "Connected := true;" takes about 2 seconds - is this normal? Can I accelerate this?
2. Is Params.Add('Server=localhost') and Params.Add('Port=3306') the correct way to connect to the server?
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Connection takes 2 seconds - normal?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 25, 2015 3:53 AM   in response to: Andrea Kaiser in response to: Andrea Kaiser
1. The "Connected := true;" takes about 2 seconds - is this normal? Can I accelerate this?

This is very bad time for local MySQL server. Moreover MySQL connections
are one of the fastest DB connections. Normally it should be ~30 msecs.

2. Is Params.Add('Server=localhost') and Params.Add('Port=3306') the correct way to connect to the server?

Yes, it is. Although these values are optional, because localhost/3306 are
the default values.

--
With best regards,
Dmitry
Andrea Kaiser

Posts: 63
Registered: 11/17/15
Re: Connection takes 2 seconds - normal?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 25, 2015 3:56 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
1. The "Connected := true;" takes about 2 seconds - is this normal? Can I accelerate this?

This is very bad time for local MySQL server. Moreover MySQL connections
are one of the fastest DB connections. Normally it should be ~30 msecs.

2. Is Params.Add('Server=localhost') and Params.Add('Port=3306') the correct way to connect to the server?

Yes, it is. Although these values are optional, because localhost/3306 are
the default values.

--
With best regards,
Dmitry

Thank you.

1. Do you have any idea, why my connection is so slow? Can I do something about it?

2. It's just a preparation, in the normal case there will be "Params.Add('Server=999.99.999.999')"
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Connection takes 2 seconds - normal?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 25, 2015 3:59 AM   in response to: Andrea Kaiser in response to: Andrea Kaiser
1. Do you have any idea, why my connection is so slow? Can I do something about it?

Many reasons.
https://www.google.com/search?q=why+mysql+connection+slow

--
With best regards,
Dmitry
Andrea Kaiser

Posts: 63
Registered: 11/17/15
Re: Connection takes 2 seconds - normal?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 25, 2015 4:01 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
1. Do you have any idea, why my connection is so slow? Can I do something about it?

Many reasons.
https://www.google.com/search?q=why+mysql+connection+slow

--
With best regards,
Dmitry

I will look into this, thanks a lot.
Andrea Kaiser

Posts: 63
Registered: 11/17/15
Re: Connection takes 2 seconds - normal?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 25, 2015 4:17 AM   in response to: Andrea Kaiser in response to: Andrea Kaiser
Andrea Kaiser wrote:
Dmitry Arefiev wrote:
1. Do you have any idea, why my connection is so slow? Can I do something about it?

Many reasons.
https://www.google.com/search?q=why+mysql+connection+slow

--
With best regards,
Dmitry

I will look into this, thanks a lot.

Just for the record, although it's a bit embarrassing for me...

For compatibility tests I ran a MySQL 5 driver with the very old MySQL 4 server. And that was the whole problem. When I tested the connection speed, I wasn't aware of that fact anymore.

With the normal server the connection is as fast as it should be. Thanks again, Dmitry.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02