Oracle query is slow (or fails) from .NET app but is fast from SQL Developer

前端 未结 4 2155
陌清茗
陌清茗 2021-02-14 09:58

We use ODP.NET to perform queries on Oracle databases, and normally it works fine. There is a particular database, and a particular view in that database, though, that we just c

4条回答
  •  甜味超标
    2021-02-14 11:01

    It had nothing to do with the ODP.NET provider. The problem was that the library we use to create connections for us (which, of course, is not used by Oracle SQL Developer, and which I did not use when I tried the Microsoft provider) was always executing the following statements before doing anything:

    ALTER SESSION SET NLS_COMP = LINGUISTIC
    ALTER SESSION SET NLS_SORT = BINARY_CI
    

    These make Oracle case-insensitive. But, they also render all conventional indexes useless. Because we were querying from a View, it had ordering built in. And because we don't own the database, we can't make the indexes linguistic to fix the performance problem.

    Providing a way to not execute those statements in this (rare) scenario fixed the problem.

提交回复
热议问题