• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List Updation

 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a List of items which is updated by several users at the same time.
Every user has got a module which continiously checks for the updation. The problem with the logic is every time it checks for the update it traverse the complete table and find out the items that has been not listed and update the list. I dont want to traverse the complete table as it takes lot of time, just want to find out the item which has been most recently added in the table, to do this I tried to add the most recent item on the list based on date and time but again I found that many time more than one user update the list simultaniously and it causes the only one item to be updated can you give me an idea how should I do that without traversing the complete table?.
 
Ranch Hand
Posts: 999
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
{
....based on date and time but again I found that many time more than one user update the list simultaniously and it causes the only one item to be updated
}
So what is the problem? You have to search for that record with max(timestamp),right?
 
Sameer Jamal
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arjunkumar Shastry:
{
....based on date and time but again I found that many time more than one user update the list simultaniously and it causes the only one item to be updated
}
So what is the problem? You have to search for that record with max(timestamp),right?



Problem is that suppose one user is updating the table at
1-1-05 12:00:00 AM with "item no 1" meanwhile second user is also updating the table with item2, my module will check for the record with maximum date time stamp which will be at present item1(item no 2 is not added yet) now third user have updated the table with item3 at 1-1-05 120:00:01 now next time when module will check for latest update it will return "item no 3", "item no 2" is lost.



[ September 21, 2005: Message edited by: Sameer Jamal ]
 
Arjunkumar Shastry
Ranch Hand
Posts: 999
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a database table,right? Write Stored procedure to scan entire table and call stored procedure from your java code.
 
Sameer Jamal
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arjunkumar Shastry:
Write Stored procedure to scan entire table and call stored procedure from your java code.



That is what I dont want to do even stored procedure take some time to traverse the complete table any other idea ?.
 
Arjunkumar Shastry
Ranch Hand
Posts: 999
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On an average,whats the row count of a table daily?
Which database are you using?
 
Sameer Jamal
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arjunkumar Shastry:
On an average,whats the row count of a table daily?
Which database are you using?



SQL Server
Row count is > 10K


Now it has become Database question this thread might move to General Computing
 
Arjunkumar Shastry
Ranch Hand
Posts: 999
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it will be moved to JDBC if I am not wrong.
 
Sameer Jamal
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arjunkumar Shastry:
I think it will be moved to JDBC if I am not wrong.



Lets talk about logic and keep it here
 
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for this one, probably i would have kept only an application scope object which will hold replica of database list.

all users should refer to same object so that they don't have any local copies.

now i will sync only one object with database so that individual list do not require sync.

as far as getting one object in sync is concerned...two easy ways will be:

1) whenever any user updates the list, i will update object and database as one logical transaction so that i don't have to read back from database and my object remains updated (except the scenario when appication needs re-initialization when object can be reloaded from database).

2) other way can be that there is a check bit in either database or in the list which tells which ones are new entries. the system than can sync up those entries..

does that make any sense?
 
Sameer Jamal
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Amit its a good suggestion but sharing a global object among various users slow down the things little bit but its a good idea.

Another approach in my mind was building a seperate table for list updation every time a new item is added it will also be added into that table for each logged on user , user will then check the item from that table and delete their corresponding entry when the list is updated.
 
Amit Agrawal
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sameer Jamal:
Thanks Amit its a good suggestion but sharing a global object among various users slow down the things little bit but its a good idea.

Another approach in my mind was building a seperate table for list updation every time a new item is added it will also be added into that table for each logged on user , user will then check the item from that table and delete their corresponding entry when the list is updated.



well my thoughts on having global object:

in your current design, probably each user has got one object which i think will ultimately be maintained in the server only. All objects shall occupy more or less same amount of memory.

To my mind, it will occupy much more space in the server if you have one object per user than having one global object. i am not sure why do you think gloabl object will slow down anything in comparison to previous design!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic