Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative of Select count(*) from TABLE

Status
Not open for further replies.

pratimsingha

Programmer
Feb 12, 2015
2
IN
Requirement:
Via kafka, data are moving from a DB2 table to a seperate database table.
Our requirement is to collect the total row count of the table in DB2 and total rowcount of table in the other database and match whether they are equal.
Expectation is that the rowcount should be same otherwise alert will be thrown.

So Spring Batch service will be designed to check everyday at some specified time, the rowcount of the tables of both the database and generate a report.

Problem:
1. select count(*) from Table in DB2 is a very expensive operation. Please consider that the total rowcount of the table will be around millions.
2. Its a leagacy database design and therefore, there is no Primary key available. But we do have unique and non unique Indexes.

Any suggestion on what can be an alternative for select count(*) from Table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top