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

dbExistsTable: Specialize for oracle #560

Closed
wants to merge 1 commit into from

Conversation

detule
Copy link
Collaborator

@detule detule commented Apr 15, 2023

Hi:

This should improve dbWriteTable performance when writing to an Oracle connection. ( See: #540 )

Notes:

  • Ideally would have liked to insert this query based approach for Oracle in dbListTables. However, for dbListTables("OdbcConnection", we advertise pattern based argument matching which is specific to the SQLTables/connection_sql_tables API; can bend the query to also do something similar but it's a bit more involved so punted for now.
  • Outstanding are connection pane performance issues for Oracle which are also related to usage of connection_sql_tables. Have an idea how to mitigate at least some of them ( listing catalogs, schemas, etc ). Will address subsequently.
  • Also in this PR, moved one of the specializations of dbExistsTable from Connection.R to Table.R, together with the remaining specializations.

@detule
Copy link
Collaborator Author

detule commented Apr 15, 2023

Just a note. Was trawling the ORACLE server side logs, and figured out that our calls to SQLTables gets translated to something that looks like:

SELECT * FROM
  ( SELECT null table_qualifier, o1.owner table_owner, o1.object_name table_name, decode(o1.owner,'SYS', decode(o1.object_type,'TABLE','SYSTEM TABLE','VIEW', 'SYSTEM VIEW', o1.object_type), 'SYSTEM', decode(o1.object_type,'TABLE','SYSTEM TABLE','VIEW', 'SYSTEM VIEW', o1.object_type), o1.object_type) table_type, null remarks
    FROM all_objects o1 WHERE o1.object_type in ('TABLE', 'VIEW')
    UNION
    SELECT null table_qualifier, s.owner table_owner, s.synonym_name table_name, 'SYNONYM' table_type, null remarks
    FROM all_objects o3, all_synonyms s
    WHERE o3.object_type in ('TABLE','VIEW') AND s.table_owner= o3.owner AND s.table_name = o3.object_name
    UNION
    SELECT null table_qualifier, s1.owner table_owner, s1.synonym_name table_name, 'SYNONYM' table_type, null remarks
    FROM all_synonyms s1 WHERE s1.db_link IS NOT NULL
  ) tables
WHERE 1=1 AND table_owner='SA' ORDER BY 4,2,3

This doesn't look all too dis-similar compared to the custom dbExistsTable implementation in this patch:

  • Looks like it includes synonyms. Probably worth looking into including those if we can make this query performant. Which brings me to second point.
  • Not sure why no subsetting is done within each of the UNION queries? Only using the table_owner filter after the union?

@detule
Copy link
Collaborator Author

detule commented Jun 9, 2023

Abandoning in favor of more comprehensive solution here

@detule detule closed this Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant