[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-users] query results not being cached?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: [odb-users] query results not being cached?
- Next message: [odb-users] query results not being cached?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the odb-users mailing list
[odb-users] query results not being cached?的更多相关文章
- [ORACLE错误]oracle 不能更新 PL/SQL 点击“edit data”报“ these query results are not updateable”
你可以选择在查询语句的最后加上 for update,就可以打开编辑锁,直接修改数据. 而在默认查询下,点击Edit data,会报错:The query results are not update ...
- File attachment or query results size exceeds allowable value of 1000000 bytes.
今天早晨,收到了作业执行失败的邮件(前几天还能正常执行该作业.不知为何今天出错) 邮件显示,作业的第三个步骤报错. step3内容: msdb.dbo.sp_send_dbmail @prof ...
- laravel路由无法访问,报404,No query results for model [App\Models\...]
今天遇到了一个问题,在routes/web.php中配置了路由,但始终无法访问该路由,一直报404. Route::resource('gift_packs', 'GiftPacksControlle ...
- troubleshooting-When importing query results in parallel, you must specify --split-by.
原因分析 -m 4 \ 导数命令中map task number=4,当-m 设置的值大于1时,split-by必须设置字段(需要是 int 类型的字段),如果不是 int类型的字段,则需要加上参数- ...
- 通过redash query results 数据源实现跨数据库的查询
redash 提供了一个简单的 query results 可以帮助我们进行跨数据源的查询处理 底层数据的存储是基于sqlite的,期望后期有调整(毕竟处理能力有限),同时 query results ...
- create a new table for the query results
http://stackoverflow.com/questions/2698401/how-to-store-mysql-query-results-in-another-table CREATE ...
- laravel报错 No query results for model . 的解决方法
这个通常由路由绑定出的问题,注意有绑定模型的路由,同路径的路由需要放在没绑定路由的后面 例如:/product/comments和/product的是同路径,/product必须放在/product/ ...
- 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 ...
- 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 ...
随机推荐
- ruby cloud9部署到heroku
Cloud9网址:https://c9.io/ 使用github账号登陆,如果没有,现在github(https://github.com/)上注册一个用户,在进行登陆.
- 集训第六周 古典概型 期望 D题 Discovering Gold 期望
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...
- vs2003 刷新项目失败。无法从服务器中检索文件夹信息
环境: 操作系统:windows server 2003 开发工具:Visual stuadio 2003 FrameWork: 1.1 打开web项目的时候报错 提示 项目刷新失败,无法从服务器 ...
- phpcms二次开发笔记
phpcms二次开发笔记 --soulsjie 以下载的全新的phpcms搭建一个新的站点为例,讲解如何利用phpcms进行二次开发 一.下载和安装phpcms http://www.phpcms.c ...
- BNUOJ 1541 Air Raid
Air Raid Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: 1 ...
- 全文搜索(A)-相关性
文章:搜索相关性 文章:推荐系统中相似度算法介绍及效果测试 文章:常用的相似度计算方法原理及实现 文章:推荐系统用户相似度计算方法研究
- ABC077翻车实况
今天强行打一波ABC,想作为信心赛,然而= = T1 日常练习读入&输出 T2 $STL$大法好,$sqrt$保平安,我强行递推$WA$了一圈,然后罚时++ T3 woc好难啊,$n=1 ...
- bzoj5105 晨跑 数论lcm
“无体育,不清华”.”每天锻炼一小时,健康工作五十年,幸福生活一辈子”在清华,体育运动绝对是同学们生活中 不可或缺的一部分.为了响应学校的号召,模范好学生王队长决定坚持晨跑.不过由于种种原因,每天都早 ...
- struct init
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h& ...
- Linux下汇编语言学习笔记62 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...