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

[odb-users] query results not being cached?的更多相关文章

  1. [ORACLE错误]oracle 不能更新 PL/SQL 点击“edit data”报“ these query results are not updateable”

    你可以选择在查询语句的最后加上 for update,就可以打开编辑锁,直接修改数据. 而在默认查询下,点击Edit data,会报错:The query results are not update ...

  2. File attachment or query results size exceeds allowable value of 1000000 bytes.

    今天早晨,收到了作业执行失败的邮件(前几天还能正常执行该作业.不知为何今天出错) 邮件显示,作业的第三个步骤报错. step3内容: msdb.dbo.sp_send_dbmail     @prof ...

  3. laravel路由无法访问,报404,No query results for model [App\Models\...]

    今天遇到了一个问题,在routes/web.php中配置了路由,但始终无法访问该路由,一直报404. Route::resource('gift_packs', 'GiftPacksControlle ...

  4. troubleshooting-When importing query results in parallel, you must specify --split-by.

    原因分析 -m 4 \ 导数命令中map task number=4,当-m 设置的值大于1时,split-by必须设置字段(需要是 int 类型的字段),如果不是 int类型的字段,则需要加上参数- ...

  5. 通过redash query results 数据源实现跨数据库的查询

    redash 提供了一个简单的 query results 可以帮助我们进行跨数据源的查询处理 底层数据的存储是基于sqlite的,期望后期有调整(毕竟处理能力有限),同时 query results ...

  6. create a new table for the query results

    http://stackoverflow.com/questions/2698401/how-to-store-mysql-query-results-in-another-table CREATE ...

  7. laravel报错 No query results for model . 的解决方法

    这个通常由路由绑定出的问题,注意有绑定模型的路由,同路径的路由需要放在没绑定路由的后面 例如:/product/comments和/product的是同路径,/product必须放在/product/ ...

  8. Save results to different files when executing multi SQL statements in DB Query Analyzer 7.01

        1 About DB Query Analyzer DB Query Analyzer is presented by Master Genfeng,Ma from Chinese Mainl ...

  9. Pitfalls of the Hibernate Second-Level / Query Caches--reference

    This post will go through how to setup the Hibernate Second-Level and Query caches, how they work an ...

随机推荐

  1. ThinkPHP5.X PHP5.6.27-nts + Apache 通过 URL 重写来隐藏入口文件 index.php

    我们先来看看官方手册给出关于「URL 重写」的参考: 可以通过 URL 重写隐藏应用的入口文件 index.php ,Apache 的配置参考: 1.http.conf 配置文件加载 mod_rewr ...

  2. Python随笔day01

    环境变量的配置: 配置Python的安装目录到path变量中,例如C:\Python37 标识符的命名规则: 变量名只能以数字,字母,下划线组成. 不能以数字开头,保留字不能被使用. 建议使用下划线分 ...

  3. 3.2.11 行 vs 字符串

        了解行(line)与字符串(string)的差异是相当重要的.大部分简易程序都是处理输入数据的行,像 grep 与 egrep,以及 sed 大部分的工作(99%)都是这样.在这些情况下,不会 ...

  4. MVC系统学习6—Filter

    Mvc的过滤器是特性类,可以使我们在执行Action之前,执行Action之后,执行Action发生异常时,编写相关的处理代码实现某些逻辑.下面是四个基本的Filter接口. 上面这四个基本的Filt ...

  5. hihoCoder 必须吐槽hihoCoder的一点 (¯Д¯)ノ

    代码输入窗口太小,mac下经常误操作:双指滑动浏览器后退 而且输入框不会自动保存,一不小心后退一下,啥都..都没了...码了好久的代码就没了..遇到不止一次了 (  ̄ .  ̄ ) (゜ ロ゜;) ( ̄ ...

  6. Pull方式解析XML文件

    package com.pingyijinren.test; import android.content.Intent; import android.os.Handler; import andr ...

  7. nyoj_176_整数划分(二)_201404261715

    整数划分(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 把一个正整数m分成n个正整数的和,有多少种分法? 例:把5分成3个正正数的和,有两种分法: 1 1 3 ...

  8. DOM节点是啥玩意?

    在 HTML DOM 中,所有事物都是节点.DOM 是被视为节点树的 HTML. DOM 节点 根据 W3C 的 HTML DOM 标准,HTML 文档中的所有内容都是节点: 整个文档是一个文档节点 ...

  9. CLR运行机制

    CLR编译器会将我们的代码编译成托管模块(中间IL语言和元数据),托管模块是一个标准的PE32执行文件,或者PE32+执行文件.但是CLR实际不和托管模块一起工作,他会将托管模块合并成程序集,程序集是 ...

  10. java设计模式——单例设计模式

    /*设计模式:对问题行之有效的解决方式.其实它是一种思想. 1,单例设计模式.    解决的问题:就是可以保证一个类在内存中的对象唯一性. 必须对于多个程序使用同一个配置信息对象时,就需要保证该对象的 ...