elGringo Posted July 27, 2016 Posted July 27, 2016 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??? Quote
adragan Posted July 27, 2016 Posted July 27, 2016 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. Quote
elGringo Posted July 27, 2016 Author Posted July 27, 2016 Yes, but second approach calls connection only in the moment program need. Quote
AlbertoVesx Posted July 27, 2016 Posted July 27, 2016 Yes, but second approach calls connection only in the moment program need. It could be a slow method Quote
zilav Posted July 27, 2016 Posted July 27, 2016 The better is multiple connections with pooling. I don't use FireDAC and don't have any idea about it's support for pooling. In the worst case you can write your own connections pool. Edit: a quick google attempt shows http://docwiki.embarcadero.com/CodeExamples/Berlin/en/FireDAC.Pooling_Sample Quote
elGringo Posted July 27, 2016 Author Posted July 27, 2016 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; Quote
zilav Posted July 28, 2016 Posted July 28, 2016 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.