How bad is IN operator for SQL query perfomance?

前端 未结 5 567
你的背包
你的背包 2021-01-16 05:05

I had SQL query that was taking 9 hours for execution. See below:

Select Field1, Field2
From A
Where Field3 IN (45 unique values here) 

Whe

5条回答
  •  再見小時候
    2021-01-16 05:21

    Poor query performance can be caused by a number of different issues, none of which I can even venture to guess would be your problem because there just isn't enough information:

    • Multiple or unnecessary joins
    • Rowcounts of joined tables
    • No indexes or indexes not being utilized by query engine
    • Out of date table statistics causing indexes to be inefficient
    • Inefficient query

    With that being said you can always get a better idea of how your query is being interpreted by the query engine by running an EXPLAIN PLAN. Here is information on how to do this for an Oracle database, http://download.oracle.com/docs/cd/B10500_01/server.920/a96533/ex_plan.htm

提交回复
热议问题