达到查询的有效性能水平

时间:2018-11-23 17:28:20

标签: sql oracle

我在oracle查询下面有这个,请告诉我如何提高效率,以提高性能,如果我是新手,请让我知道ii是否缺少任何内容,任何早期帮助都将是很多赞赏

以下是查询计划,请告知我该如何改进

Plan hash value: 44516869

---------------------------------------------------------------------------------------------------
| Id  | Operation                     | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT              |                   |  1099 | 39564 |  3770   (1)| 00:00:46 |
|*  1 |  HASH JOIN                    |                   |  1099 | 39564 |  3770   (1)| 00:00:46 |
|   2 |   NESTED LOOPS                |                   |       |       |            |          |
|   3 |    NESTED LOOPS               |                   |  1095 | 32850 |  3345   (1)| 00:00:41 |
|   4 |     TABLE ACCESS FULL         | BUSINESS_CONTACTS |  1666 | 14994 |    11   (0)| 00:00:01 |
|*  5 |     INDEX UNIQUE SCAN         | PERSON_PK         |     1 |       |     

1 个答案:

答案 0 :(得分:0)

首先,您可以使用正确的,明确的,标准 JOIN语法和无子查询来重写查询。我相信查询是:

select p.business_name as Aggregator_Name, 
       pc.business_name as Child_Business_Name, 
       bc.IDV_STATUS 
from business_contacts bc join
     person p
     on bc.person_id = p.person_id join
     person pc
     on pc.parent_person_id = p.person_id;

然后针对此查询,您希望在person(person_id, business_name)person(parent_person_id, business_name)上建立索引。