title: C# How to get all data in Oracle database
body: <p>I have 21 tables in Oracle 11g, and I need to display them using <code>JOIN</code> clauses. But the query is too slow and throws an <code>System.OutOfMemoryException</code></p>
  
  <p>My current code:</p>
  
  <pre><code>   try
          {
              //string ConString;
              using (OracleConnection con = new OracleConnection(ConString))
              {
                  //string query = "SELECT PAX.CREATION_DATE,PAX.PNR,PAX.PAX_NMBR,PAX.UPDATE_LEVEL_MOD,PAX.PAX_NAME,PAX.CHANGE_OR_CANCEL_IND,PAX_SEATS.LEG_NMBR,PAX_SEATS.INSTANCE_NMBR,pax_seats.ssr_cd,pax_seats.carrier_cd,pax_seats.seat_nmbr,pax_seats.previous_status_codes FROM PAX INNER JOIN PAX_SEATS ON PAX.PNR = PAX_SEATS.PNR";
                  string query1 = "SELECT PNR FROM HISTORY_LEGS";
                  string query2 = "SELECT PAX.CREATION_DATE,PAX.PNR,PAX.PAX_NMBR,PAX.UPDATE_LEVEL_MOD,PAX.PAX_NAME,PAX.CHANGE_OR_CANCEL_IND,PAX_SEATS.LEG_NMBR,PAX_SEATS.INSTANCE_NMBR,pax_seats.ssr_cd,pax_seats.carrier_cd,pax_seats.seat_nmbr,pax_seats.previous_status_codes,PAX_SSRS.SSR_NMBR,PAX_TKT.TKTNMBR,PAX_TKT.ISSUING_AIRLINE, PAX_TKT.ISSUING_OFFC_NMBR, PAX_TKT.ISSUING_COUNTER_CD, PAX_TKT.ISSUING_AGNT_NMBR, PAX_TKT.TKT_IND, PAX_TKT.TKT_STATUS, PAX_TKT.TARIFICATION_IND,PAX_TKT.S_IND,PAX_TKT.ISSUANCE_DATE FROM PAX INNER JOIN PAX_SEATS ON PAX.PNR = PAX_SEATS.PNR RIGHT JOIN PAX_SSRS ON PAX.PNR = PAX_SSRS.PNR RIGHT JOIN PAX_TKT ON PAX.PNR = PAX_TKT.PNR";
                  //string query4 = "SELECT * FROM PAX";
                  //string query3 = "SELECT PAX.PAX_NMBR,PAX.PAX_NAME,RES_LEGS.ARNK_IND,RES_LEGS.CARRIER_CD1,RES_LEGS.CARRIER_CD2,RES_LEGS.FLT_NMBR,RES_LEGS.CLASS_CD,RES_LEGS.DAY_OF_WEEK,RES_LEGS.FLT_DATE,RES_LEGS.LEG_ORIGIN_CD,RES_LEGS.LEG_DES_CD,RES_LEGS.CURRENT_STATUS_CD,RES_LEGS.NUMBER_IN_PARTY,RES_LEGS.DP_TIME,RES_LEGS.AR_TIME,RES_LEGS.DATE_CHANGE_IND,RES_LEGS.FLT_IRREGULARITY_IND,RES_LEGS.LEG_TXT,RES_LEGS.PREVIOUS_STATUS_CODES,RES_LEGS.MESSAGE FROM RES_LEGS INNER JOIN PAX ON RES_LEGS.PNR = PAX.PNR";
                  OracleCommand cmd = new OracleCommand(query2, con);
                  OracleDataAdapter oda = new OracleDataAdapter(cmd);
                  DataSet ds = new DataSet();
                  oda.Fill(ds);
                  //dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
                  //dataGridView1.RowHeadersVisible = false;
                  if (ds.Tables.Count &gt; 0)
                  {
                      dataGridView1.DataSource = ds.Tables[0].DefaultView;
                  }
  
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.ToString());
          }
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li>How to get all data? </li>
  <li>How to prevent System.OutofMemory? </li>
  <li>How to speed up query execution performance?</li>
  </ol>