Hi,
Using Delphi 10.1 Update 2, SQL Server 2012 and PostgreSQL 9.6.2.
My application uses prepared statements using TUniQuery.Prepare() when TUniQuery.Options.AutoPrepare set to False. Preparing is done at the time of application creation.
These prepared queries are not calling TUniQuery.UnPrepare() at the time of application terminate.
I am wondering;
1- Does TUniQuery has a feature to call UnPrepare() automatically at the time of execution of TUniQuery.Free()?
2- Assuming TUniQuery is not automatically calling UnPrepare, will such a usage described above can be a problem for me?
3- Is there a performance difference/server overhead, etc. when using TUniQuery.Options.AutoPrepare set to True and the method I described above.
4- I know that UniDAC has connection pooling. Does it also have Prepared Statement Pooling?
Thanks.
Way of using prepared statements and some related questions
Re: Way of using prepared statements and some related questions
1,2 - In the TUniQuery destructor there is code call that regardless of the value in TUniQuery.Options.AutoPrepare calls UnPrepare if dataset was prepared.
3- For the described case there will not be any performance difference because when setting TUniQuery.Options.AutoPrepare to True the same method Prepare will be called
4 - When placing a connection to pool UniDAC will call the UnPrepare method for each dataset that uses this connection and was prepared.
3- For the described case there will not be any performance difference because when setting TUniQuery.Options.AutoPrepare to True the same method Prepare will be called
4 - When placing a connection to pool UniDAC will call the UnPrepare method for each dataset that uses this connection and was prepared.
Re: Way of using prepared statements and some related questions
Hi azyk,
About Number 3:
a- My initial post is calling prepare one time, at the time form is created.
b- When TUniQuery.Options.AutoPrepare is set to True, TUniQuery is calling Prepare each time there is a call to TUniQuery.Open()
My question about performance/server overhead etc was mostly regarding item b above as using this way or TUniQuery there will be lots of prepare/unprepare calls thru the life of the application compared to item a which is just one prepare/unprepare call.
About Number 3:
a- My initial post is calling prepare one time, at the time form is created.
b- When TUniQuery.Options.AutoPrepare is set to True, TUniQuery is calling Prepare each time there is a call to TUniQuery.Open()
My question about performance/server overhead etc was mostly regarding item b above as using this way or TUniQuery there will be lots of prepare/unprepare calls thru the life of the application compared to item a which is just one prepare/unprepare call.
Re: Way of using prepared statements and some related questions
If TUniQuery.Options.AutoPrepare is set to True, then when calling TUniQuery.Open UniDAC will not prepare a query on the server again if TUniQuery has been already prepared.