row_number()over(按varchar2列的顺序)在oracle 12c中花费更多时间?

时间:2017-08-30 04:37:58

标签: sql oracle oracle12c

我在表上应用row_number()(通过varchar2列的顺序)有200万条记录,但在oracle 12c中花费的时间更多。

计划哈希值:193104477

-----------------------------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name                           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                                |  1631K|   628M|       |   257K  (1)| 00:00:11 |
|   1 |  WINDOW SORT                 |                                |  1631K|   628M|   670M|   257K  (1)| 00:00:11 |
|*  2 |   HASH JOIN                  |                                |  1631K|   628M|  8128K|   117K  (1)| 00:00:05 |
|   3 |    TABLE ACCESS FULL         | SYS_USER                       |   108K|  6856K|       |  2466   (1)| 00:00:01 |
|*  4 |    HASH JOIN                 |                                |  1631K|   527M|  2608K| 87280   (1)| 00:00:04 |
|   5 |     TABLE ACCESS FULL        | CHANGE_REQUEST                 | 45210 |  2075K|       |  3850   (1)| 00:00:01 |
|*  6 |     HASH JOIN                |                                |  1632K|   454M|  3800K| 59840   (1)| 00:00:03 |
|   7 |      TABLE ACCESS FULL       | SYS_USER                       |   108K|  2531K|       |  2467   (1)| 00:00:01 |
|*  8 |      HASH JOIN               |                                |  1632K|   417M|  7800K| 35566   (1)| 00:00:02 |
|*  9 |       HASH JOIN              |                                | 62854 |  7058K|       |  1826   (1)| 00:00:01 |
|  10 |        INDEX FAST FULL SCAN  | COMPINDEX_SYSID_NAME_NI        |  2716 |   143K|       |    15   (0)| 00:00:01 |
|  11 |        VIEW                  | index$_join$_003               | 69097 |  4116K|       |  1810   (1)| 00:00:01 |
|* 12 |         HASH JOIN            |                                |       |       |       |            |          |
|* 13 |          INDEX FAST FULL SCAN| I001823ASSIGNMENT_GROUPSYSAPPR | 69097 |  4116K|       |  1008   (0)| 00:00:01 |
|  14 |          INDEX FAST FULL SCAN| SYSAPPROVAL_GROUP_SYS_ID       | 69097 |  4116K|       |   743   (0)| 00:00:01 |
|  15 |       TABLE ACCESS FULL      | SYSAPPROVAL_APPROVER           |  1841K|   268M|       | 18984   (1)| 00:00:01 |

以下是我正在使用的查询。

SELECT cr.number_x AS UNIQUE_KEY,
        row_number() over(ORDER BY sa.sys_id) AS COUNTER,
        sa.sys_updated_on AS "DATE"
FROM snowdb.sysapproval_approver sa,
     snowdb.change_request cr,
     snowdb.sysapproval_group sag,
     snowdb.sys_user_group sug,
     snowdb.sys_user su,
     snowdb.sys_user su1
WHERE sa."GROUP_X"=sag.sys_id
  AND sa.sysapproval=cr.sys_id
  AND sag.assignment_group=sug.sys_id
  AND sa.approver=su.sys_id
  AND sa.sys_updated_by=su1.employee_number

0 个答案:

没有答案