开发者社区> double2li> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

[odb-users] query results not being cached?

简介: Burton, Craig crburton at tnsi.com Wed Jun 6 13:58:03 EDT 2012   Previous message: [odb-users] query results not being cached? Next message: [odb...
+关注继续查看

Burton, Craig crburton at tnsi.com 
Wed Jun 6 13:58:03 EDT 2012

 


Hi Boris,

My apologies; I see now (with some embarrassment) that this specific Oracle limitation is well documented.

Under many circumstances, our application expects to find exactly zero or one instance for many specific queries, but finding two or more would lead to an error scenario.  Application logic is the following in many such cases:

        if zero instances, create a new one
        if one instance, update the one found in the db
        if two or more, do nothing and return an error

Your alternative approach using the view works well for my needs, since I can determine the count and then perform the query if there is, indeed, only one instance.  I don't see a clean way to do the same by only iterating over the result, unless the iteration determines the count and temporarily holds a reference to the single instance (if there is only one).  I'll continue to try a few different approaches to see which one is most compatible with our current implementation.

Thanks again for your help!

Craig

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Wednesday, June 06, 2012 12:15 AM
To: Burton, Craig
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] query results not being cached?

Hi Craig,

Burton, Craig <crburton at tnsi.com> writes:

> I am not able to call "size()" on query results even if I try to use
> the "cache()" method on the results template.

For some databases (right now Oracle, SQLite, and MS SQL Server),
caching (and therefore size()) is not supported. This is documented
in the database-specific chapters. For Oracle that would be Section
16.5.2, "Query Result Caching":

http://www.codesynthesis.com/products/odb/doc/manual.xhtml#16.5.2

If you are interested, in the case or Oracle, supporting size() would
require switching the query result cursor to the scrollable mode. This
results in a much worse performance compared to the forward-only mode.
There is also a long and complicated list of limitations of scrollable
cursors that stipulate the kind of situations that are not supported
(specifically, support for BLOB/LONG types is very limited).

So it is better to try not to rely on knowing in advance the number
of entries in the result. Specifically, any optimizations that you
may want to make (e.g., reserve the space in the vector, etc), will
be inconsequential compared to the cost of supporting size(). If
you really need to know the size prior to the iteration, then the
best you can do is probably run a separate query that returns the
count, for example:

#pragma db view object(MyPersistentClass)
struct MyPersistentClassCount
{
  #pragma db column("count(*)")
  std::size_t count;
};

size_t count = ora_db->query<MyPersistentClassCount> (pred)->begin ()->count;

Boris

This e-mail message is for the sole use of the intended recipient(s)and may
contain confidential and privileged information of Transaction Network Services.
Any unauthorised review, use, disclosure or distribution is prohibited. If you
are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.



 


More information about the odb-users mailing list

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
解决 lupdate warning: no TS files specified.
解决 lupdate warning: no TS files specified.
0 0
A query was run and no Result Maps were found for the Mapped Statement
A query was run and no Result Maps were found for the Mapped Statement
0 0
Error TS6138 - Property xxxx is declared but its value is never read
Error TS6138 - Property xxxx is declared but its value is never read
0 0
[20180609]Wrong Results with IOT, Added Column and Secondary Index2.txt
[20180609]Wrong Results with IOT, Added Column and Secondary Index2.txt --//链接:http://db-oriented.
993 0
[20150924]result cache problem.txt
[20150924]result cache problem.txt --昨天看了连接,看到一个关于result cache的例子,重复测试看看: --链接 https://jonathanlewis.
652 0
[20150715]Wrong Results.txt
[20150715]Wrong Results.txt http://afatkulin.blogspot.com/2015/07/wrong-results.html --重复测试: SCOTT@test> @ver1 PORT_STRING    ...
649 0
Unable to save result set
Unable to save result set 今天碰到这个问题了,经过我的测试,原因是数据量太大, 得方案:     1。修改php.ini文件的merroy_limit的值  (试过了不起作用)     求更好的方案!     
356 0
Multiple Server Query Execution报The result set could not be merged..
在SQL Server中使用Multiple Server Query Execution这个功能做数据库维护或脚本发布时非常方便,昨天由于磁盘空间原因,删除清理了大量的软件和组件,结果导致SSMS客户端出了问题,重装过后,使用Multiple Server Query Execution时,出现了...
562 0
+关注
double2li
一个在IT行业摸爬滚打的老司机
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Semantic Search--Fast Results from Large,Foreign Language Corpora
立即下载
Why you should care about data layout in the file system
立即下载
How to Build a Successful Data Lake
立即下载