Page 1 of 1

One ZConnection and many data aware components?

Posted: 06.10.2007, 09:46
by ccezar
Hello,

I've finished coding stored procedures in my database and now it's time for user interface. I'm coding it in Delphi 7 with (surprise!) ZeosLib ;-)

The question is: which model is better from the performance and interoperability point of view?

1) One TZconnection component on the form, reused simultaneously by many datasources and dataware compontets?
2) Dedicated TZconnection component for each datasource existing on the form?

I'm using PostgresQL, so connection limit is not the issue.

Thank you in advance for any suggestions! :-)

Cezar

Posted: 06.10.2007, 12:21
by jozagulikoza
Mainly one TZConnection per aplication in a datamodul.

if you have TZConnetction per dataset and 10 datasets in your apl.
yuo have 10 real connenctons on DB serverve.
Imagine one aplication/user 10 connections on DB.
And imagine you have 15 users work with your program, 15X10 connectons.

Posted: 06.10.2007, 18:56
by ccezar
OK. Doesn't it hurt TZconnection performance?

Posted: 06.10.2007, 19:39
by mdaems
As long as you don't use multiple independent theads all queries are run one by one anyway.

Posted: 06.10.2007, 19:42
by ccezar
Well, I'm using threads. What will be ZConnection behaviour in this case? Will it be "blocking queue"?

Posted: 06.10.2007, 20:04
by mdaems
No idea...
All I can tell is that the database connection library is only loaded once. So maybe you get trouble when 2 connections use the same library. When connecting using different libraries you might be lucky the connections work 'simultaneously'.
Somebody else with more usefull information concerning threaded programs in combination with zeoslib?

Mark

Posted: 07.10.2007, 12:26
by jozagulikoza
If you use treads, yes open a connecton per tread
Can you tell us in which case you use treads.
Generali if you use trasacitons in your stored procedures it is enought, no needs for treafds.
I need more informations about your databese/aplication design.

Posted: 08.10.2007, 14:21
by btrewern
FYI - I've been using Zeos in a multi-threaded Delphi app for some time now. It uses IntraWeb to produce a web application and the only problem I've had was with the TZSQLMonitor which was not completely thread safe.

BTW always use one TZConnection per thread.

Regards,

Ben

Posted: 08.10.2007, 17:45
by jozagulikoza
Its good exaple for multitreading and good design ;).
I havent proper solution for TZSQLMonitor in treads.
But, its not big problem for me.