简体   繁体   English

Oracle SQL 或 PLSQL 随负载扩展

[英]Oracle SQL or PLSQL scale with load

Suppose I have query ( it has joins on multiple tables ) and assuming it is tuned, and optimized.假设我有查询(它在多个表上有连接)并假设它已经过调整和优化。 This query runs on the target database/tables with N number of records and query results R number of records and takes time T. Now gradually the load increases and say the target records become N2, and result it give is R2 and time it takes as T2.此查询在目标数据库/表上运行,有 N 条记录,查询结果为 R 条记录,耗时 T。现在负载逐渐增加,假设目标记录变为 N2,结果为 R2,所需时间为T2。 Assuming that I have allocated enough memory to the Oracle, L2/L1 will be close to T2/T1.假设我给Oracle分配了足够的内存,L2/L1会接近T2/T1。 Means the proportional increase in the load will result proportional increase in execution time.意味着负载按比例增加将导致执行时间按比例增加。 For this question lets say L2 = 5L1, means load has increased to 5times.对于这个问题,假设 L2 = 5L1,意味着负载增加到 5 倍。 Then time take to complete by this query would also be 5times or little more, right?那么完成此查询所需的时间也将是 5 倍或更多,对吗? So, to reduce the proportional growth in time, do we have options in Oracle, like parallel hint etc?那么,为了减少时间的比例增长,我们在 Oracle 中有选项吗,比如并行提示等? In Java we split the job in multiple threads and 2times the load with 2times the worker thread we get almost same time to complete.在 Java 中,我们将作业拆分为多个线程,将 2 倍的负载与 2 倍的工作线程进行几乎相同的时间完成。 So with increasing load we increase the worker thread and achieve the scaling issue reasonably well.因此,随着负载的增加,我们增加了工作线程并合理地解决了缩放问题。 Is such thing possible in Oracle or does Oracle take care of such thing in the back end and will scale, by splitting the load internally into parallel processing?这种事情在 Oracle 中是否可行,或者 Oracle 是否会在后端处理此类事情并通过将负载内部拆分为并行处理来扩展? Here, I have multi core processors.在这里,我有多核处理器。 I Will experiment it, but if expert opinion is available it will help.我会试验它,但如果有专家意见,它会有所帮助。

No. Query algorithms do not necessarily grow linearly.不。查询算法不一定线性增长。

You should probably learn something about algorithms and complexity.您可能应该了解一些有关算法和复杂性的知识。 But many algorithms used in a data are super-linear.但是数据中使用的许多算法都是超线性的。 For instance, ordering a set of rows has a complexity of O(n log n), meaning that if you double the data size, the time taken for sorting more than doubles .例如,对一组行进行排序的复杂度为 O(n log n),这意味着如果将数据大小加倍,则排序所花费的时间将增加一倍以上

This is also true of index lookups and various join algorithms.索引查找和各种连接算法也是如此。

On the other hand, if your query is looking up a few rows using a b-tree index, then the complex is O(log n) -- this is sublinear.另一方面,如果您的查询使用 b 树索引查找几行,则复杂度为 O(log n)——这是次线性的。 So index lookups grow more slowly than the size of the data.因此索引查找的增长速度比数据的大小要慢。

So, in general you cannot assume that increasing the size of data by a factor of n has a linear effect on the time.因此,通常您不能假设将数据大小增加n倍对时间有线性影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM