Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying table node is very slow #11

Closed
PhilippSalvisberg opened this issue Jul 12, 2017 · 1 comment
Closed

Querying table node is very slow #11

PhilippSalvisberg opened this issue Jul 12, 2017 · 1 comment
Assignees
Labels

Comments

@PhilippSalvisberg
Copy link
Contributor

Querying the table node takes the first time around 30 seconds. GUI is blocked during the time.

The reason is most probably the named query hist_tabs following query (based on SQL Developer statement history):

WITH 
  tabs AS (
     SELECT /*+ materialize */ object_name AS table_name
       FROM user_objects
      WHERE object_type = 'TABLE'
        AND generated = 'N'
   ),
   hist_tabs AS (
      SELECT /*+ materialize */ table_name
        FROM user_tab_cols
       WHERE column_name = 'VT$'
         AND hidden_column = 'YES'
   ),
   pk_tabs AS (
      SELECT /*+ materialize */ table_name 
        FROM all_constraints
        WHERE constraint_type = 'P' AND owner = USER
   )
SELECT /*+ordered use_hash(tabs) use_hash(hist_tabs) use_has(pk_tabs) */ tabs.table_name
  FROM tabs
  JOIN pk_tabs ON pk_tabs.table_name = tabs.table_name 
  LEFT JOIN hist_tabs ON hist_tabs.table_name = tabs.table_name
 WHERE hist_tabs.table_name is NULL
 ORDER BY tabs.table_name
@PhilippSalvisberg
Copy link
Contributor Author

This should be better:

WITH 
  tabs AS (
     SELECT /*+ materialize */ object_name AS table_name
       FROM user_objects
      WHERE object_type = 'TABLE'
        AND generated = 'N'
   ),
   cols AS (
      SELECT /*+ materialize */ table_name, column_name, hidden_column
        FROM user_tab_cols
   ),
   hist_tabs AS (
      SELECT DISTINCT table_name
        FROM cols
       WHERE column_name = 'VT$'
         AND hidden_column = 'YES'
   ),
   pk_tabs AS (
      SELECT /*+ materialize */ table_name 
        FROM all_constraints
        WHERE constraint_type = 'P' AND owner = USER
   )
SELECT /*+ordered use_hash(tabs) use_hash(hist_tabs) use_hash(pk_tabs) */ tabs.table_name
  FROM tabs
  JOIN pk_tabs ON pk_tabs.table_name = tabs.table_name 
  LEFT JOIN hist_tabs ON hist_tabs.table_name = tabs.table_name
 WHERE hist_tabs.table_name is NULL
 ORDER BY tabs.table_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant