title: Really Slow Performance Reading from Access 2007 (accdb) file from C#
body: <p>I am writing an application on Visual Studio 2008 with C#. The application reads data from an access file and then generates a txt file. I was doing some tests with a mdb file with 1.000.000 records and almost 1GB size.
  The code is like this and the overall process was taking between 8 - 10 minutes to complete.</p>
  
  <pre><code>var connStr =  string.Format("Provider =Microsoft.Jet.OLEDB.4.0; Data Source={0};Persist Security Info=False", this.dbPath);
  
  using (var conn = new OleDbConnection(connStr))
  {
              using (var command = conn.CreateCommand())
              {   
  
                  command.CommandText = "SELECT * from Registros r, FOIDS f where r.TICKET = f.TICKET";
                  command.CommandType = System.Data.CommandType.Text;
                  conn.Open();
  
                  int i = 0;
                  string ticket = string.Empty;
  
                  using (var reader = command.ExecuteReader())
                  {
                      while (reader.Read())
                      {
                           i++;
  
                              if (!reader.IsDBNull(reader.GetOrdinal("r.TICKET")))
                              {
                                  ticket=reader.GetString(reader.GetOrdinal("r.TICKET"));
                                  // Some process
                              }
                          }
                      }
                  }
            }
      }
  </code></pre>
  
  <p>Today I received an accdb file (Access 2007), so I've changed my connection string to this one:</p>
  
  <pre><code>connStr = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=False", this.dbPath);
  </code></pre>
  
  <p>But after that change, reading the new file is taking about 4-5 seconds per record !!! So, my overall process would take a lot of DAYS to complete!
  I've tried converting the accdb file to an old mdb file and after that reading again with the previous connection string, but the problem remains. I think is a problem with the database itself but I don't know what to do, in internet i didn't found any information with this kind of problem.</p>
  
  <p>Any ideas? Suggestions?</p>