CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Interest Calculation Job

  1. #1

    Interest Calculation Job

    Hi,

    A program is written in C that uses database. It calculates interest of 1 crore accounts and updates the tables in the database. It does lot of validations before calculating interest of an account.e..g It does not calculate interst of dormant account. This job is taking 3 days for execution. What are the alternates to improve the performance.

    i. Can I write a shell script to do this job? Will be there any performance improvement?
    ii. Can I write a store procedure instead of C.

    Pl suggest various effectie alternatives.

  2. #2
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,593

    Re: Interest Calculation Job

    I don't know if this is homework or not, but without a lot more details about what it's doing now, it's hard to say how to do it better.

    What's a crore?

  4. #4
    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    379

    Re: Interest Calculation Job

    "A crore is a unit in the Indian numbering system equal to ten million"

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,593

    Re: Interest Calculation Job

    Quote Originally Posted by alanjhd08 View Post
    "A crore is a unit in the Indian numbering system equal to ten million"
    That's not a really huge number. I can't imagine if taking three days for a computer to do 10 million interest calculations.

  6. #6

    Re: Interest Calculation Job

    This is not homework...Question is related to design......What are the common tips to do such 10 million interst calculation? Pl give me pointer of any article...

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Interest Calculation Job

    Quote Originally Posted by forumuser11@gmail.com View Post
    Question is related to design......What are the common tips to do such 10 million interst calculation?
    You identify what part of the application is slow, and then you improve it.

    Regards,

    Paul McKenzie

  8. #8
    Join Date
    May 2002
    Posts
    1,435

    Re: Interest Calculation Job

    Quote Originally Posted by GCDEF View Post
    That's not a really huge number. I can't imagine if taking three days for a computer to do 10 million interest calculations.
    I am by no means an expert on databases, but if it really does take three days to do 10 million updates then that works out to about 38.58 calculations per second - or 25.92 ms per calculation - which doesn't sound unreasonable to me. For a simple C program, yes, that's slow. But for a database that has to update tables in addition to doing the calculations? Maybe not. For a system with a remote back end and a large number of users, that may actually be fast.

    Even though the program is written in C, I wonder if a database forum might provide more relevant info.

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,593

    Re: Interest Calculation Job

    Quote Originally Posted by 0xC0000005 View Post
    I am by no means an expert on databases, but if it really does take three days to do 10 million updates then that works out to about 38.58 calculations per second - or 25.92 ms per calculation - which doesn't sound unreasonable to me. For a simple C program, yes, that's slow. But for a database that has to update tables in addition to doing the calculations? Maybe not. For a system with a remote back end and a large number of users, that may actually be fast.

    Even though the program is written in C, I wonder if a database forum might provide more relevant info.
    He didn't say if he's updating the database or anything about what he's doing. Whatever it is, it shouldn't take more than a few minutes at most. Possibly he's doing a lot of queries of unindexed fields, but who knows. It certainly doesn't take three days to write 10 million records to a database.

  10. #10
    Join Date
    May 2002
    Posts
    1,435

    Re: Interest Calculation Job

    Quote Originally Posted by GCDEF View Post
    He didn't say if he's updating the database or anything about what he's doing. Whatever it is, it shouldn't take more than a few minutes at most. Possibly he's doing a lot of queries of unindexed fields, but who knows. It certainly doesn't take three days to write 10 million records to a database.
    With all due respect to your outstanding reputation here, it all boils down to whether or not you agree that 1/40 of a second is a long time to access a database record from a local C program, do some calculations, then update the record. In order for this to happen in a few (3 for example) minutes as you suggest, the rate would have to be nearly 56,000 updates per second or 18 microseconds per update. Probably more than reasonable for a C program in the absence of a database - but for the reasons I mentioned before: for example, an enterprise system with lots of users and a remote back end - I do not think it is necessarily reasonable.

    Granted, I am assuming inefficient access - grab a single account, calculate interest, then update the database - but that is my interpretation. Again, I don't claim to be an expert on database access, it's just my humble opinion.

  11. #11
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,593

    Re: Interest Calculation Job

    Quote Originally Posted by 0xC0000005 View Post
    With all due respect to your outstanding reputation here, it all boils down to whether or not you agree that 1/40 of a second is a long time to access a database record from a local C program, do some calculations, then update the record. In order for this to happen in a few (3 for example) minutes as you suggest, the rate would have to be nearly 56,000 updates per second or 18 microseconds per update. Probably more than reasonable for a C program in the absence of a database - but for the reasons I mentioned before: for example, an enterprise system with lots of users and a remote back end - I do not think it is necessarily reasonable.

    Granted, I am assuming inefficient access - grab a single account, calculate interest, then update the database - but that is my interpretation. Again, I don't claim to be an expert on database access, it's just my humble opinion.
    I work with databases a lot. He hasn't said what he's doing so there's no point in speculating, but if it takes more than a few minutes, something is really wrong. As I said, I my best guess is a lot of queries on large unindexed tables, but there's no way of telling unless he explains himself better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)