Currently I need to run two queries to get both the total amount of items in my resultset as well as the resultset. Is it possible to just get the resultset count as well as the resultset in one pass to the database. I am trying to optimize my code so I don’t have to make 2 passes to the database as these individual select statements already take minutes to run. I am looking for a solution in both oracle sql and ms sql because I use both. I am also using Microsoft’s Oracle access libraries to get to the Oracle database and not the Oracle access libraries.
Share
There is no property of OracleCommand or oracleDataReader that shows the fetched rows. The number of rows is known after fetchin all rows.
But if you fetch all data into an resultset, then you have the row count in
resultset.Tables[0].Rows.Countas stated above. This has no extra costs on the database, because the Count is a property of the row collection. The index number depends on the amount of tables in your resultset.