Table of Contents
11. Index Storage
Index is a special file in the database, which allows Valentina Kernel to do fast searches and sorting on fields.
Ownership of Index Files
- Each field can have one index.
- Each calculation field can have one index.
- Table keeps multi-column compound indexes if any.
- One-field Index belongs to one [Calculated] Field
- Multi-column Index belongs to Table.
- If a field is deleted, then all its files including index are deleted.
- If a table is delete, then all its files including indexes are deleted.
Index Files on Volume
Indexes contain secondary type of information in the database. This means that we can trash/lost it and easily rebuild it again using primary information stored in the database tables.
Taking this fact into account, Valentina database has a special volume for indexes with the default extension “.ind”.
Advantages of separate volume are:
- This reduces the risk of corruption of main information stored in the “.dat” volume, because some amount of operations is performed on another volume.
- This gives us easy way to trash this volume, while db is closed, and on the next open Valentina will rebuild all required indexes.
NOTE: Developer can specify VDatabase.Mode when “.ind” volume do not exists as separate, but we here discuss DEFAULT ABILITY of Valentina Kernel to have all indexes on a separate “.ind” volume.
Indexes of System Tables
System Tables keep own data (i.e. records) not in the “.dat” volume, but on the “.vdb” volume. But indexes of the system tables still are created on the “.ind” volume.
Indexes of Temporary Tables
Temporary Tables based on disk, keep own data not in the “.dat” volume, but on the temporary “.tmp” volume. Here also are stored indexes of temporary Tables and Fields. Valentina do this to avoid pressure on the “.ind” volume by temporary tables, which can be very often created/destroyed.
Indexes of RAM Tables
All internal logical files of a RAM table are also RAM files. So indexes not go to .ind volume of course.