Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Inserting rows into master table from multiple threads
<sameergn_at_gmail.com> schreef in bericht news:0c6a4c21-b8fa-4b91-9625-c8e1426c2c69_at_s12g2000prg.googlegroups.com...
> On Dec 19, 9:30 pm, DA Morgan <damor..._at_psoug.org> wrote:
>>>> >> VARCHAR. A strong clue that you are not dealing with Oracle as someone
>> >> First of all this is Oracle not SQL Server so the data type is not
>>>> >> it should be generated by a sequence object making a collision
>> >> Second what is the form of your primary key? If it is a surrogate key
>>>> >> system design a duplicate is highly unlikely so you should just to the
>> >> Third, assuming a natural key and a possible collision which is more
>> >> likely? A duplicate or a non-duplicate? Assuming some competence in
>>>> >> damor..._at_x.washington.edu (replace x with u to respond)
>> >> Again, as at OTN where you posted the exact same question, it appears
>> >> you think Oracle is SQL Server ... it is not.
>> >> --
>> >> Daniel A. Morgan
>> >> Oracle Ace Director & Instructor
>> >> University of Washington
>>
>>>> > character columns. Anyway, that was just an example and not real
>> > This code is for Oracle 10g database. I meant varchar2, but wrote
>> > varchar just to keep it generic, pseudo-code like, to indicate a
>>>> > recommended approach for inserting a new master row in a multi-
>> > I have seen "select ... for update" construct when you want to
>> > atomically get and update a row, but was not sure what is the
>>
>>
>>
>>
>>
>>
> > We are trying to log HTTP requests from tomcat to a database table. > This would include URL, referrer, user agent (browser), HTTP method > (GET/POST) etc. It would require lot of space if we log all the > character data as it is, so we decided to normalize it, but all > possible values of URL, referrer, UA are not known in advance. So a > master table for them will be built on the fly as and when new data > arrives. It may then be possible for two threads to create an entry in > master table at the same time. > > With this approach, contention would arise only during initial phase, > when master table is being built. After some time most of the values > would go into master table and their ID will always be found while > inserting access log record. > > ( I am aware of the AccessLogValve mechanism provided by Tomcat but we > are logging some application specific data in each row and making > these inserts using a separate thread to minimize impact on service > processing thread)
In this case I think you should follow Daniels design and just ignore the exceptions (but keep the exceptions clause in your code, just put null; in it) : if the value is already there, it's no problem. Only problem might be that in time you will only get exceptions, and no new records.
Shakespeare Received on Thu Dec 20 2007 - 02:13:48 CST
![]() |
![]() |