如何禁用 oracle 缓存进行性能测试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2179512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:22:26  来源:igfitidea点击:

How to disable oracle cache for performance tests

oraclecachingoracle10gperformance

提问by Custodio

I'm trying to test the utility of a new summary table for my data.

我正在尝试为我的数据测试新汇总表的效用。

So I've created two procedures to fetch the data of a certain interval, each one using a different table source. So on my C# console application I just call one or another. The problem start when I want to repeat this several times to have a good pattern of response time.

所以我创建了两个过程来获取特定时间间隔的数据,每个过程都使用不同的表源。所以在我的 C# 控制台应用程序中,我只调用一个或另一个。当我想重复几次以获得良好的响应时间模式时,问题就开始了。

I got something like this: 1199,84,81,81,81,81,82,80,80,81,81,80,81,91,80,80,81,80

我得到了这样的东西:1199,84,81,81,81,81,82,80,80,81,81,80,81,91,80,80,81,80

Probably my Oracle 10g is making an inappropriate caching.

可能我的 Oracle 10g 进行了不适当的缓存。

How I can solve this?

我该如何解决这个问题?

采纳答案by Peter Lang

EDIT:See this thread on asktom, which describes howand why notto do this.

编辑:在 asktom 上看到这个线程,它描述了如何以及为什么不这样做。

If you are in a test environment, you can put your tablespace offline and online again:

如果您处于测试环境中,您可以将您的表空间脱机并再次联机:

ALTER TABLESPACE <tablespace_name> OFFLINE;
ALTER TABLESPACE <tablespace_name> ONLINE;

Or you can try

或者你可以试试

ALTER SYSTEM FLUSH BUFFER_CACHE;

but again only on test environment.

但同样仅限于测试环境。

When you test on your "real" system, the times you get after first call (those using cached data) might be more interesting, as you will have cached data. Call the procedure twice, and only consider the performance results you get in subsequent executions.

当您在“真实”系统上进行测试时,您在第一次调用(使用缓存数据的那些)之后获得的时间可能更有趣,因为您将拥有缓存数据。调用该过程两次,只考虑在后续执行中获得的性能结果。

回答by APC

Probably my Oracle 10g is making a inappropriate caching.

可能我的 Oracle 10g 进行了不适当的缓存。

Actually it seems like Oracle is doing some entirely appropriate caching. If these tables are going to be used a lot then you would hope to have them in cache most of the time.

实际上,Oracle 似乎正在做一些完全合适的缓存。如果这些表将被大量使用,那么您希望大部分时间都将它们放在缓存中。

edit

编辑

In a comment on Peter's response Luis said

在评论彼得的回应时,路易斯说

flushing before the call I got some interesting results like: 1370,354,391,375,352,511,390,375,326,335,435,334,334,328,337,314,417,377,384,367,393.

在通话前冲洗我得到了一些有趣的结果,例如:1370,354,391,375,352,511,390,375,326,335,435,334,334,328,337,314,417,377,384,367,393。

These findings are "interesting" because the flush means the calls take a bit longer than when the rows are in the DB cache but not as long as the first call. This is almost certainly because the server has stored the physical records in its physical cache. The only way to avoid that, to truely run against an empty cache is to reboot the serverbefore every test.

这些发现是“有趣的”,因为刷新意味着调用比行在 DB 缓存中花费的时间要长一些,但不像第一次调用那么长。这几乎可以肯定是因为服务器已将物理记录存储在其物理缓存中。避免这种情况的唯一方法,真正针对空缓存运行是在每次测试之前重新启动服务器

Alternatively learn to tune queries properly. Understanding how the database worksis a good start. And EXPLAIN PLAN is a better tuning aid than the wall-clock. Find out more.

或者学习如何正确调整查询。了解数据库的工作原理是一个好的开始。EXPLAIN PLAN 是比挂钟更好的调整辅助工具。 了解更多。