![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a question on select count(), which may betray my lack of database knowledge. Here goes. I have java code driving a transaction which goes like this: select count(*) from table (Java code in the same transaction) if count < 50 then ... insert into table values(blahblah) commit; it seems that if many of these transactions are running concurrently, count could exceed 50 unless oracle locks the table for inserts or deletes. Am I getting this wrong ? Are there better solutions ? |
#3
| |||
| |||
|
|
I have a question on select count(), which may betray my lack of database knowledge. Here goes. I have java code driving a transaction which goes like this: select count(*) from table (Java code in the same transaction) if count < 50 then ... insert into table values(blahblah) commit; it seems that if many of these transactions are running concurrently, count could exceed 50 unless oracle locks the table for inserts or deletes. Am I getting this wrong ? Are there better solutions ? |
#4
| |||
| |||
|
| If you are trying to restrict number of rows to <= 50, there is something wrong with database design. It'll help if you post what you are trying to achieve (in simple words)... |

#5
| |||
| |||
|
|
afilonov (AT) yahoo (DOT) com (Alex Filonov) wrote in message news:<336da121.0408161150.2c0d78d9 (AT) posting (DOT) google.com>... If you are trying to restrict number of rows to <= 50, there is something wrong with database design. It'll help if you post what you are trying to achieve (in simple words)... Are you saying I was unclear ? ![]() I keep track of sessions in a database. Exceeding a fixed number of sessions should not be allowed. |
|
The reason I do not keep the cound in the Java application was that I wanted to keep the application stateless, to allow for simple load balancing. I thought the database could help me, but at the same time, I think helping me, the database would sacrifice a lot of performance. |
#6
| |||
| |||
|
|
afilonov (AT) yahoo (DOT) com (Alex Filonov) wrote in message news:<336da121.0408161150.2c0d78d9 (AT) posting (DOT) google.com>... If you are trying to restrict number of rows to <= 50, there is something wrong with database design. It'll help if you post what you are trying to achieve (in simple words)... Are you saying I was unclear ? ![]() I keep track of sessions in a database. Exceeding a fixed number of sessions should not be allowed. The reason I do not keep the cound in the Java application was that I wanted to keep the application stateless, to allow for simple load balancing. I thought the database could help me, but at the same time, I think helping me, the database would sacrifice a lot of performance. Why not just set the parameter in the init.ora file that restricts the |
#7
| |||
| |||
|
|
afilonov (AT) yahoo (DOT) com (Alex Filonov) wrote in message news:<336da121.0408161150.2c0d78d9 (AT) posting (DOT) google.com>... If you are trying to restrict number of rows to <= 50, there is something wrong with database design. It'll help if you post what you are trying to achieve (in simple words)... Are you saying I was unclear ? ![]() I keep track of sessions in a database. Exceeding a fixed number of sessions should not be allowed. The reason I do not keep the cound in the Java application was that I wanted to keep the application stateless, to allow for simple load balancing. I thought the database could help me, but at the same time, I think helping me, the database would sacrifice a lot of performance. |
#8
| ||||
| ||||
|
|
You mean, each session is registering itself in some table? Maybe you can use v$session virtual table? |

|
Another way is to create a table with fixed number of rows. Would create a lot of headache: you need to update a row when session is registering itself and update again when it's de-registering (and you need a monitor which would detect dead session and de-register them). Another problem with this design is that session needs to connect to database to try to register itself... |
|
The reason I do not keep the cound in the Java application was that I wanted to keep the application stateless, to allow for simple load balancing. I thought the database could help me, but at the same time, I think helping me, the database would sacrifice a lot of performance. Maybe not. Depends on what kind of operations do you do against the database. BTW, do you really need to restrict the number of sessions? |
|
And, is it possible to use restrictions built-in into Oracle, like restrictions on number of sessions, processes or transactions? |
![]() |
| Thread Tools | |
| Display Modes | |
| |