superche
superche

Reputation: 773

Java app continuously check new rows added in table

I have a scenario: we have a big table (it is split into a few small ones), I want to use trigger to track the change. We will insert rows to a tracking table if the big table has insert, update and delete event. I need to build a Java app to continuously check the tracking table to see if there are rows left there, fetch them back, do some computation, update cache and delete them.
My question is what is the most efficient way to implement it?
Some concerns:

Upvotes: 0

Views: 1494

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533880

This sounds like you are trying to implement a queue in a database. JMS may be a better choice.

You can periodically poll the table to find entries. If IDs have to be groups together, I assume you need some way of knowing that the ID is complete.

If your IDS are incrementing in size, you can include the next 200 IDs in your query. e.g. WHERE id < {id-up-to} + 200

Upvotes: 1

Related Questions