Subject Re: [firebird-support] The PHP default transaction
Author Mark Rotteveel
On Thu, 21 Jan 2016 10:44:10 +0000, "Tim Ward tdw@...
[firebird-support]" <> wrote:
> I've got a long running (hours) PHP script which does large numbers
> (tens of thousands) of database operations along the lines of
> start explicit transaction
> do something in that transaction
> commit that transaction
> the idea being not to hold any individual transaction open for a long
> time and, thereby, not to open up a transaction number gap and hold up
> garbage collection.
> But we see from the MON$ tables what looks like a transaction that
> starts at the beginning of the script and remains in existence
> throughout the lifetime of the script. This transaction is marked
> "inactive".
> (1) Is this likely to be the "default transaction" that PHP creates for
> a connection if you don't do an explicit start transaction? Ie, does PHP

> create the default transaction for a connection even if you never use it

> (rather than create it on first use, as one might have hoped)?
> (2) What, if anything, is the import of a transaction being marked
> "inactive"? Does an "inactive" transaction still freeze the various
> transaction counters and hold up garbage collection?
> (3) If the answer to (2) is that the existence of this transaction *is*
> a potential performance problem, I imagine I can get rid of it simply by

> doing "ibase_commit();" at the start of the PHP script?

You might want to show a sample of code of what you do.

To me your question suggests you are executing a script containing START
TRANSACTION and COMMIT statements, and therefor ignoring the transaction
handling of the driver. A lot of drivers don't "like" transaction
statements, as they are in control of transactions. If that is the case, I
am not sure if you will be able to do this in PHP without having that long
running transaction, as drivers will usually start an implicit transaction
when none is available when you start execution of a statement. In that
case calling ibase_commit() won't help.

If you are using the transaction features of the PHP ibase driver, then
you might get a better answer at the firebird-php mailinglist as they are
probably more familiar with its inner workings of the driver.