热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

iPhone上的SQLite临时表存储-TemporarytablestoreinSQLiteontheiPhone

IusetemporarytablesinanSQLitebasediPhoneapplication.Performancewasnotaswasrequiredso

I use temporary tables in an SQLite based iPhone application. Performance was not as was required so I looked at various candidates for optimization. Most of these worked well and had the desired effect. However, I'd also like to try moving the temporary tables from flash into memory to see if there is any improvement.

我在基于SQLite的iPhone应用程序中使用临时表。性能不是所需的,所以我查看了各种候选优化。其中大多数都运作良好并具有预期效果。但是,我还想尝试将临时表从闪存移动到内存中,看看是否有任何改进。

On an actual device I try and configure this using:

在实际设备上,我尝试使用以下方法配置:

PRAGMA temp_store = 2;

These executes without error. However, when I query the configuration using:

这些执行没有错误。但是,当我使用以下方式查询配置时:

PRAGMA temp_store;

No results are returned so I am unable verify that this configuration is in effect. I can read other PRAGMA settings such as 'page_size'. Can anyone tell me:

没有返回结果,因此我无法验证此配置是否有效。我可以阅读其他PRAGMA设置,例如'page_size'。谁能告诉我:

  • If this is expected behavior
  • 如果这是预期的行为

  • If this is an unsupported configuration in SQLite on the iPhone
  • 如果这是iPhone上SQLite中不支持的配置

  • If such an optimization would be pointless on the iPhone even if it were possible (due perhaps to the hardware)
  • 如果这样的优化在iPhone上毫无意义,即使它是可能的(可能由硬件引起)

  • How I can successfully move temporary table storage into memory in this scenario
  • 在这种情况下,如何将临时表存储成功移动到内存中

Note: I am well aware of Core Data in SDK 3.0 but I have good reasons for not using it.

注意:我很清楚SDK 3.0中的核心数据,但我有充分的理由不使用它。

Update: jitter pointed out that the SQLite instance on the iPhone may have been compiled with SQLITE_TEMP_STORE set to always use temporary files. I wasn't aware of this setting - is there any way to confirm that this is the case?

更新:jitter指出iPhone上的SQLite实例可能已经编译,SQLITE_TEMP_STORE设置为始终使用临时文件。我不知道这个设置 - 有没有办法确认是这种情况?

2 个解决方案

#1


I just added the SQLite source myself to my projects, because the SQLite on at least the iPhone OS 2.x is not thread safe.

我刚刚将SQLite源自己添加到我的项目中,因为至少iPhone OS 2.x上的SQLite不是线程安全的。

#2


I don't know but guess they compiled the sqllite with SQLITE_TEMP_STORE=0. And there is another guy who tried this and didn't succeed. SQLite optimization on the iPhone

我不知道,但他们猜测他们用SQLITE_TEMP_STORE = 0编译了sqllite。还有另一个人试过这个并没有成功。 iPhone上的SQLite优化

  • List item

I can't try it out myself but there seems to be a sqlite3TempInMemory() function in the source too (src/main.c). Don't know if you can call that.

我不能自己尝试,但在源代码中似乎也有一个sqlite3TempInMemory()函数(src / main.c)。不知道你是否可以打电话。

This function returns true if main-memory should be used instead of a temporary file for transient pager files and statement journals. The value returned depends on the value of db->temp_store (runtime parameter) and the compile time value of SQLITE_TEMP_STORE. The following table describes the relationship between these two values and this functions return value.

如果应使用主内存而不是临时文件用于临时寻呼机文件和语句日志,则此函数返回true。返回的值取决于db-> temp_store(运行时参数)的值和SQLITE_TEMP_STORE的编译时间值。下表描述了这两个值之间的关系以及此函数的返回值。


推荐阅读
author-avatar
陈俊凯660638
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有