Skip to content

Slow query, can it be replaced? #2429

@matthewtusker

Description

@matthewtusker

SELECT owner, table_name, 'TABLE' name_type
FROM all_tables
WHERE owner = :table_owner
AND table_name = :table_name
UNION ALL
SELECT owner, view_name table_name, 'VIEW' name_type
FROM all_views
WHERE owner = :table_owner
AND view_name = :table_name
UNION ALL
SELECT table_owner, table_name, 'SYNONYM' name_type
FROM all_synonyms
WHERE owner = :table_owner
AND synonym_name = :table_name
UNION ALL
SELECT table_owner, table_name, 'SYNONYM' name_type
FROM all_synonyms
WHERE owner = 'PUBLIC'
AND synonym_name = :real_name
SQL

The above query is hitting us hard in Production. I'm seeing ~2s responses for this query. Our dbas have suggested that it could be replaced with the following:

SELECT owner,object_name 
FROM all_objects 
WHERE owner=:table_owner 
  AND object_name=:table_name 
  AND object_type in ('TABLE','VIEW','SYNONYM');

I don't know enough about the inner workings of Oracle to know whether this is a useful improvement and whether it would work over all the supported versions of Oracle for this Gem. Can someone with a bit more knowledge provide me with some insight here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions