Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:19:59+00:00 2026-05-31T22:19:59+00:00

i am working on a section of a project, that parses Logs from Postgres

  • 0

i am working on a section of a project, that parses Logs from Postgres Database Server.
The application is developed in C sharp Framework 4.0.

A log is produced and displayed on a DataGridView with the following columns

resultCode       Statement                  Starttime                   Duration
XT001         select * from PizzaMade    01-02-2012 03:10:14         00:04:10
  • there are many loglines with the sameformat.
  • The Datagridview is filled from another loop by parsing a Textfile.

My work is to generate stats from the data available in Grid in the following format

Statement                                 Count        countpercent                    Occurs_on

select * from PizzaMade                     3             1.42        01/02 at 03pm   [00:04:10], 01/02 at 04 [00:01:04]
select id,qty,table from PizzaMade          12             5.12           ...........

so basically the stats reflect the following

  • a) statement executed
  • b) Count number of times it appears in a grid
  • c) percentage of count which is basically the portion of totalcounts this statement occupies
  • d) a concatenated string containing starttime,duration

» The stats are generated as Datatable first, using a for loop

foreach(DataGridViewRow dr in LogGrid.Rows)
{
// search in the Datatable if the statement is present
// if it is then add count , add starttime and duration to the column
// if not then add a newrow

}

» After populating the datatable , i use a loop to calculate the Totalcount

int totalcount = 0;
foreach (DataRow drin StatTable.Rows)
{
totalcount = totalcount + Convert.ToInt32(dr["count"].ToString());
}

» After calculating the count, there is a loop to calculate the percentage

foreach (DataRow dr in StatTable.Rows)
{
    int c = Convert.ToInt32(dr["count"].ToString());
    dr["countpercent"] = (c/totalcount)*100;
}

Although everything seems ok, the whole method is sluggish with large number of rows.

  • Can you please suggest methods to improve the performance.

thanks
arvind

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:20:00+00:00Added an answer on May 31, 2026 at 10:20 pm

    Since you’re parsing text logs it might enhance performance by operating not in grid but in objects. Also, the grid could be bound to the List of parsed logs. It could be like this:

    public class LogItem
    {
        public string ResultCode { get;set;}
        public string Statement { get;set;}
        public DateTime StartTime { get;set;}
        public TimeSpan Duration { get;set;}
    }
    

    Then your grid could be bound to BindingList which contains all parsed log items. While having the list, you could access data in more uniform way:

    foreach (string statement in logItems.Select(x => x.Statement).Distinct())
    {
        int count = logItems.Count(x => x.Statement == statement);
        double percentage = count / logItems.Count(); 
        // any additional data
    }
    

    If you’d like to be extra performant and fancy, you could save all parsed log files to database and create queries for necessary data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a long string grabbed from a Session that uses § (Section
I am working on a personal project that uses a custom config file. The
I am working on a project that requires imploding an array with character separation.
I'm working on a project that surveys the condition of a road or highway
I am working on a project that has a uitableview with 3 rows in
I am working on an existing project that has two areas that can be
I'm working on a project that has a glade GUI. I need the main
I'm working on a project that has an ExpandableListView nested inside a regular ListView
as opposed to writing your own library. We're working on a project here that
I'm working on a brand new project for a state government agency that we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.