1
Answer

Slow Array Parsing (using Lists)

Will Read

Will Read

14y
11.5k
1
Hi All,

I'm loading in some data from an Oracle DB and finding it's reaaaaaally slow. It's about 65,000 customers I'm loading in and it takes about 30 mins to run.

I've tried a few different array types and settled on List (I read that the strongly typed collection was one of the best), but it's bloody awful.

Any ideas what I'm doing wrong?


<CODE>
     class Customer : IComparable
     {
         //create a constructor
         public Customer()
         {
 
         }
 
         public string Code;
         public string Name;
         public string GenericPriceListName;
         public string GenericPriceListType;
         public string PriceList;
         public string DiscountList;
         public string ExceptionList;
         public string PromotionList;
 
 
         // implement IComparable interface
         public int CompareTo(object obj)
         {
             if (obj is Customer)
             {
                 return this.Code.CompareTo((obj as Customer).Code);  // compare user names
             }
             throw new ArgumentException("Object is not a Customer");
         }
 
    }
    
 class Program
 {
 
  private static List<Customer> GetCustomerList(OleDbConnection myOleDbConnection)
        {
            OleDbCommand myOleDbCommand;
            OleDbDataReader myOleDbDataReader;
            List<Customer> listOfCustomers = new List<Customer>();

            myOleDbCommand = myOleDbConnection.CreateCommand();

            StringBuilder sqlStatement = new StringBuilder();
            sqlStatement.Append("Select * from Customers");


            myOleDbCommand.CommandText = sqlStatement.ToString();


            myOleDbDataReader = myOleDbCommand.ExecuteReader();


            

            while (myOleDbDataReader.Read())
            {

                Customer currentCustomer = new Customer();
                currentCustomer.Code = myOleDbDataReader.GetString(0);
                currentCustomer.Name = myOleDbDataReader.GetString(1);
                currentCustomer.GenericPriceListName = myOleDbDataReader.GetString(2);
                currentCustomer.GenericPriceListType = myOleDbDataReader.GetString(3);

                listOfCustomers.Add(currentCustomer);

                Console.WriteLine(string.Format("Extracting account {0}", currentCustomer.Name));
            }

            myOleDbDataReader.Close();
            myOleDbCommand.Dispose();


            return listOfCustomers;
        }
}
</CODE>



Answers (1)
0
Crish
NA 3.7k 76.4k 14y
Hi

There are many different types of jobs in computer hardware. If you like working with your hands and are interested in how computers and networks function, this may be the ideal field for you.

If you want to more detail about computer hardware than go for this below link.

http://jobs.lovetoknow.com/Jobs_in_Computer_Hardware
0
Sam Hobbs
NA 28.7k 1.3m 14y