ITPub博客

首页 > 数据库 > 数据库开发技术 > Timesten内存数据库的架构

Timesten内存数据库的架构

原创 数据库开发技术 作者:logzgh 时间:2007-12-28 16:16:19 0 删除 编辑

由于项目需要采用timesten,于是来了个突击。

幸好timesten比较简单,研究起来也较快。

后面将陆续有几篇关于timesten的文章。

[@more@]

(缺图)


Checkpoint and log files
Checkpoint files contain an image of the database on disk. TimesTen uses dual
checkpoint files for additional safety, in case the system fails while a checkpoint
operation is in progress. Changes to databases are captured in transaction logs
that are written to disk periodically. If a database needs to be recovered,
TimesTen merges the database checkpoint on disk with the completed
transactions that are still in the log files. Normal disk file systems are used for
checkpoints and log files.


Replication
For maximum performance, the replication agent detects updates to a database by
monitoring the existing transaction log. It sends updates to the subscribers in
batches, if possible. Only committed transactions are replicated. On the
subscriber node, the replication agent updates the database through an efficient
low-level interface, avoiding the overhead of the SQL layer.


Cache Connect architecture

Cache groups support the following features:
• Applications can read from and write to cache groups.
• Cache groups can be refreshed from Oracle data automatically or manually.
• Updates to cache groups can be propagated to Oracle tables automatically or manually.
• Changes to either Oracle tables or the cache group can be tracked automatically.

A cache group table can contain all or a subset of the rows and columns in the related Oracle table.


事务隔离级别
Timesten具有两种级别:
Read committed isolation
Serializable isolation


锁级别:
Database-level locking
Table-level locking
Row-level locking

可以通过ttLockLevel存储过程设置


优化器
timesten一样具有优化器,真是麻雀虽小,却五脏俱全啊。
有优化器,同样有统计信息。
Timesten的统计信息存在SYS.TBL_STATS and SYS.COL_STATS两张基表中。
可以调用ttOptUpdateStats存储过程来更新统计信息。


Hint
在timesten中设置hint需要通过内置存储过程来实现。
比如ttOptUseIndex,ttOptSetOrder


索引
Timesten采用两种索引结构:
T-tree索引
Hash索引

TimesTen uses T-tree indexes, which are optimized for main memory access. T-tree indexes are more economical than B-trees
because they require less memory space and fewer CPU cycles.
Multiple NULL values are permitted in a unique T-tree index.


Hash indexes are created for tables with a primary key when the UNIQUE HASH INDEX clause is specified in the CREATE TABLE statement.
There can be only one hash index for each table.
In general, hash indexes are faster than T-tree indexes for exact match lookups and equijoins.
However, hash indexes cannot be used for lookups involving ranges or the prefix of a key
and can require more space than T-tree indexes.


Join方式
Nested loop join
Merge join


日志
The TimesTen log is used for the following purposes:
• Redo transactions if a system failure occurs
• Undo transactions that are rolled back
• Replicate changes to other TimesTen databases
• Replicate changes to an Oracle database
• Enable applications to monitor changes to tables through the XLA interface
By default, TimesTen keeps logs in an in-memory transaction log buffer and also stores them on disk.


When are log files deleted?
Log files are kept until TimesTen declares them to be purgeable. A log file
cannot be purged until all of the following actions has been completed:
• All transactions writing log records to the log file (or a previous log file) have committed or rolled back
• All changes recorded in the log file have been written to the checkpoint files on disk
• All changes recorded in the log file have been replicated (if replication is used)
• All changes recorded in the log file have been propagated to Oracle (if Cache Connect is used)
• All changes recorded in log files have been reported to the XLA applications (if XLA is used)

Disabling logging
When logging is disabled, transactions cannot be rolled back and only databaselevel
locking is allowed. Disable logging only for operations like bulk loads of tables and only if the following conditions are true:
• The operation can be restarted from the beginning if a failure occurs.
• The application performing the bulk load is the only application connected to the database.
Use the Logging connection attribute to disable logging.


Checkpointing
Checkpoints are used to keep a snapshot of the database.
The checkpoint operation scans the database for blocks that
have changed since the last checkpoint. It then updates the checkpoint file with
the changes and removes any log files that are no longer needed.

TimesTen provides two kinds of checkpoints:
Nonblocking checkpoints
Blocking checkpoints (可以通过调用ttCkptBlocking存过来实现,会hold整个库,但是数据库是一致的,不需要恢复)
TimesTen creates nonblocking checkpoints automatically.

Recovery from log and checkpoint files
During recovery, the latest checkpoint file is read into memory and all durably
committed transactions are rolled forward from the appropriate log files.
Uncommitted or rolled-back transactions are not recovered.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/100091/viewspace-996003/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    97
  • 访问量
    983402