查询多个Oracle数据库性能问题
我在两个数据库的这些表中都有超过一百万条记录。 我正在尝试找出跨数据库表中的数据。
SELECT COUNT(*) FROM DB1.MYTABLE WHERE SEQ_NO NOT IN(SELECT SEQ_NO FROM DB2.MYTABLE) AND FILENAME NOT LIKE '%{%'
and PT_TYPE NOT IN(15,24,268,284,285,286,12,17,9,290,214,73) AND STTS=1
查询需要很长时间。有什么办法可以让它快点吗?
提前感谢您的帮助
I have over million records in these tables in both the databases.
I am trying to figure out data in both the tables acros databases.
SELECT COUNT(*) FROM DB1.MYTABLE WHERE SEQ_NO NOT IN(SELECT SEQ_NO FROM DB2.MYTABLE) AND FILENAME NOT LIKE '%{%'
and PT_TYPE NOT IN(15,24,268,284,285,286,12,17,9,290,214,73) AND STTS=1
The query is taking ages. Is there any way I can make it fast?
Appreciate your help in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您实际上是指不同的数据库吗?或者你的意思是不同的模式?您谈论不同的数据库,但语法似乎使用两个不同模式中的表,而不是两个不同的数据库。我没有看到任何对数据库链接的引用,如果有两个不同的数据库,则需要该链接,但也许
DB2.MYTABLE
应该是MYTABLE@DB2
的同义词。如果您可以发布生成的查询计划,将会很有帮助。指示存在哪些索引以及每个谓词的选择性程度也很有用。 修改查询
我的猜测是,如果由于 SCHEMA2.MYTABLE 中存在 SEQ_NO 而消除了 SCHEMA1.MYTABLE 中的大多数行,则 可能会更有效/代码>。
Do you actually mean different databases? Or do you mean different schemas? You talk about different databases but the syntax appears to be using tables in two different schemas, not two different databases. I don't see any references to a database link which would be needed if there were two different databases but perhaps
DB2.MYTABLE
is supposed to be a synonym forMYTABLE@DB2
.It would be helpful if you could post the query plan that is generated. It would also be useful to indicate what indexes exist and how selective each of these predicates is. My guess is that modifying the query to be
might be more efficient if most of the rows in
SCHEMA1.MYTABLE
are eliminated because theSEQ_NO
exists inSCHEMA2.MYTABLE
.