Yii2模式扫描ALL_OBJECTS而不是USER_OBJECTS?

时间:2017-12-18 14:23:25

标签: php oracle yii yii2

为什么Yii2使用ALL_OBJECTS扫描架构,然后按OWNER =" owner_name"进行过滤而不只是扫描USER_OBJECTS?

由于某些原因,扫描ALL_OBJECTS时查询需要很长的执行时间(45秒),查询USER_OBJECTS时需要大约2秒钟。 (生产环境)

SELECT
    A.COLUMN_NAME,
    A.DATA_TYPE,
    A.DATA_PRECISION,
    A.DATA_SCALE,
    A.DATA_LENGTH,
    A.NULLABLE,
    A.DATA_DEFAULT,
    COM.COMMENTS AS COLUMN_COMMENT
FROM ALL_TAB_COLUMNS A
    INNER JOIN ALL_OBJECTS B ON B.OWNER = A.OWNER AND LTRIM(B.OBJECT_NAME) = LTRIM(A.TABLE_NAME)
    LEFT JOIN ALL_COL_COMMENTS COM ON (A.OWNER = COM.OWNER AND A.TABLE_NAME = COM.TABLE_NAME AND A.COLUMN_NAME = COM.COLUMN_NAME)
WHERE
    A.OWNER = 'owner_name'
    AND B.OBJECT_TYPE IN ('TABLE', 'VIEW', 'MATERIALIZED VIEW')
    AND B.OBJECT_NAME = 'object_name'
ORDER BY A.COLUMN_ID

由于

1 个答案:

答案 0 :(得分:0)

访问ALL_*次观看/同义词和USER_*次观看/同义词之间存在差异。

ALL_OBJECTS描述当前使用可访问的所有对象,而USER_OBJECTS仅列出属于当前用户的对象。