.Net - Creating an On-Demand recordset rather than pulling everything into memory at once

前端 未结 2 1191
情深已故
情深已故 2021-01-23 14:02

I don\'t know if this title makes sense, but my situation is as follows:

I\'m writing a .Net program to query an Oracle DB for an enormous amount of history (about 2-yea

相关标签:
2条回答
  • 2021-01-23 14:35

    OracleCommand.ExecuteReader method doesn't load all data up front. It only provides you with OracleDataReader which you then use to load data. It's not specified if OracleDataReader loads data up front, and how much of it, but it does not bluntly pull in all the data requested by the query.

    You can even specify that the reader should only pull in field by field from single row in cases when you have large blobs of data. This is done using CommandBehavior.SequentialAccess.

    0 讨论(0)
  • 2021-01-23 14:40

    The OracleDataReader won't put all records in memory. Look at the Fetchsize property this controls the amount of records actually cached until we need a second roundtrip to the database.

    If you want Oracle to return rows faster eg., you can try the

    /*+ FIRST_ROWS(n) */
    

    hint in your query vs the

    /*+ ALL_ROWS */ 
    

    hint if you can wait for all the data.

    0 讨论(0)
提交回复
热议问题