Subject | Re: [IBO] Newbie transaction questions |
---|---|
Author | Jason Wharton |
Post date | 2002-12-10T05:47:16Z |
You should use a prepared statement with input parameters if you are going
to be executing it more than once.
You should have the insert of a master and its detail records within the
context of a single unit of work. You can use the default transaction or an
explicit one that you use for this. Keep in mind a TIBODatabase will default
to AutoCommit as true and a TIB_Transaction will default to AutoCommit as
false.
It depends on the AutoCommit setting and whether or not you have called
StartTransaction (which will appropriately suspend AutoCommit behavior.)
Rather than think of short transactions are better, make sure you are not
screwing up the integrity of your data just to serve transactions.
Transactions in InterBase/Firebird are purely a mechanism to assist you in
your efforts to have data integrity. Many other databases have transactions
to be something that dictates rather than serve. With InterBase/Firebird a 5
minute transaction is no big deal at all. You just have to make sure you
don't get a transaction started and left open indefinitely.
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
-- We may not have it all together --
-- But together we have it all --
to be executing it more than once.
You should have the insert of a master and its detail records within the
context of a single unit of work. You can use the default transaction or an
explicit one that you use for this. Keep in mind a TIBODatabase will default
to AutoCommit as true and a TIB_Transaction will default to AutoCommit as
false.
It depends on the AutoCommit setting and whether or not you have called
StartTransaction (which will appropriately suspend AutoCommit behavior.)
Rather than think of short transactions are better, make sure you are not
screwing up the integrity of your data just to serve transactions.
Transactions in InterBase/Firebird are purely a mechanism to assist you in
your efforts to have data integrity. Many other databases have transactions
to be something that dictates rather than serve. With InterBase/Firebird a 5
minute transaction is no big deal at all. You just have to make sure you
don't get a transaction started and left open indefinitely.
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
-- We may not have it all together --
-- But together we have it all --
----- Original Message -----
From: "Joe Martinez" <joe@...>
To: "IB Objects" <IBObjects@yahoogroups.com>
Sent: Monday, December 09, 2002 11:52 AM
Subject: [IBO] Newbie transaction questions
> I have a process where I'm inserting one master record, and several
> (approx. 1-50) detail records. I converted my app over from the BDE to
> IBO, and for some reason, this particular process got slower when I
> switched, as I'm hearing complaints from my customers about it.
>
> Anyway, I'm currently just using two TIBOTable objects for the two tables,
> and doing the Insert(), FieldByName(), Post() thing (once for the master
> record and multiple times for the detail records). I'm looking to speed
it
> up, so I am planning on generating the SQL myself for the inserts, using
> TIB_DSQL objects to execute them.
>
> Some questions:
>
> 1) Seeing that there are generally less than 50 detail records, would
there
> be any appreciable speed difference using a prepared parameterized query,
> rather than just re-generating the SQL each time?
>
> 2) For this whole procedure, would there be any benefit to explicit
> transaction control, or would I be fine to just use the default
transaction?
>
> 3) If I use the default transaction, when will each insert be committed?
>
> 4) If I use explicit transaction control, should the whole thing be one
> transaction, or should it be split up? One transaction for the master,
and
> one for all the detail records? A new transaction for each insert? I'm
> thinking that the shorter the transactions the better, to minimize key
> conflicts with other clients, but I'm not sure about the performance
> implications.
>
> Thanks,
> Joe
>
>
>
>
___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
> without the need for BDE, ODBC or any other layer.
>
___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info
papers,
> keyword-searchable FAQ, community code contributions and more !
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>