Jump to content

Recommended Posts

Posted

I use firedac but for my question it doesn't matter.

 

What is better?

 

To use 1 connection with DB or Many?

 

1 connection is like

 In mainUnit I create FDConnection:TFDConnection and everywhere in other modules I will use link to that

 

Many Connections means

 For Every procedure of every module I will Create Connection like

   procedure MyProcInSomeModule;
   var FDConnectionLocal:TFDConnection;
   begin
   
   FDConnectionLocal:=TFDConnection.Create(Self);
  
   //Do something;

   FreeAndNil(FDConnectionLocal);
   
   end;

Sometimes in MYSQL i meet "Too many connections" that's why I ask.

 

What is your experience. What is normal practice???

 

Posted

In MainModule you create a connection. All DB objects from other forms and frames link to that connection.

It's more economic in terms of database connections.

Posted

Thank you, Zilav. 

multiple connections with pooling ? How much multuple? One for the unit, one for the procedure,function, one for the program?))

About pooling - yes - very useful information - i've read it monthes ago but have forgotten for the moment.

 

Now - i'm rewriting app to have one connection for the thread. One Connection for the main thread and others for each thread created in program. As I understand docs - it is correct;

Posted

Usually the size of pool is set to an average expected number of clients to work at the same time. However pools are dynamic and will expand if more connections are required. Check FireDAC docs.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...