hans explained it exactly right.
A transaction only really does something at the first moment a connection is used for that client
Before that it is only state inside the client.
(startTransaction doesnt result in a call to the server at all)
jcompagner wrote:(startTransaction doesnt result in a call to the server at all)
jcompagner wrote:But how do you do your selects? Select for update? else you still are not sure that it is consistent..
Transaction-Level Read Consistency
Oracle also offers the option of enforcing transaction-level read consistency. When a transaction runs in serializable mode, all data accesses reflect the state of the database as of the time the transaction began. This means that the data seen by all queries within the same transaction is consistent with respect to a single point in time, except that queries made by a serializable transaction do see changes made by the transaction itself. Transaction-level read consistency produces repeatable reads and does not expose a query to phantoms.
Read committed This is the default transaction isolation level. Each query executed by a transaction sees only data that was committed before the query (not the transaction) began. An Oracle query never reads dirty (uncommitted) data.
Because Oracle does not prevent other transactions from modifying the data read by a query, that data can be changed by other transactions between two executions of the query. Thus, a transaction that runs a given query twice can experience both nonrepeatable read and phantoms.
Serializable Serializable transactions see only those changes that were committed at the time the transaction began, plus those changes made by the transaction itself through INSERT, UPDATE, and DELETE statements. Serializable transactions do not experience nonrepeatable reads or phantoms.
Read-only Read-only transactions see only those changes that were committed at the time the transaction began and do not allow INSERT, UPDATE, and DELETE statements.
Set the Isolation Level
Application designers, application developers, and database administrators can choose appropriate isolation levels for different transactions, depending on the application and workload. You can set the isolation level of a transaction by using one of these statements at the beginning of a transaction:
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET TRANSACTION READ ONLY;
To save the networking and processing cost of beginning each transaction with a SET TRANSACTION statement, you can use the ALTER SESSION statement to set the transaction isolation level for all subsequent transactions:
ALTER SESSION SET ISOLATION_LEVEL SERIALIZABLE;
ALTER SESSION SET ISOLATION_LEVEL READ COMMITTED;
ROCLASI wrote:jcompagner wrote:But how do you do your selects? Select for update? else you still are not sure that it is consistent..
No, just selects. My writes are done in db transactions. When I do, lets say, 3 selects to build up a report or export and after select 1 another client saves data then my select 2 and 3 might fetch (related) data that select 1 didn't have. Hence the use of a db transaction for a select.
Although now you make me wonder that this might not work the way I expect it to work...
Edit: I see I need to set the isolation level of the transaction to 'SERIALIZABLE' to be able to do that (on Pg).
Users browsing this forum: No registered users and 7 guests