Attributes are in-memory structures for fields:
Attributes can be:
|Single-valued, fixed size||Like the "A" attribute, example a 32 bit integer attribute. The element size is the size of the type, like 8 bit for a byte. A memory buffer holding all values in an array.|
|Multi-valued, fixed/variable size||Like the "B" attribute, example array of integer. A memory buffer holding references (32 bit) to a memory structure with objects for each size class.|
|Single-valued, variable size||Like the "C" attribute, example string. One large memory buffer holding references (32 bit) to a memory structure with objects per unique value.|
Use attribute when the field is used in:
- word-match search
- numerical search
- prefix search
- ranking functions
- document summaries
- document reference
Attributes speed up query execution and document updates, trading off memory. As data structures are regularly optimized, consider both static and temporary resource usage - refer to the attribute sizing guide.
Use attributes in document summaries to limit accesses to storage to generate result sets.
Using attribute for a field means query matching works on memory structures only. Note that a basic attribute is a linear array-like data structure - matching documents means scanning all attributes. Setting fast-search generates an B-tree index structure for quicker lookup, using more memory. See when to use fast-search.
A partial update can update memory structures with high throughput and low latency without having to read the original copy from the document store. The Vespa search core maintains separate data structures for the document sub databases, where only the ready sub database is in memory. For systems deployed with searchable-copies configured to a lower value than redundancy one should consider making also the not ready sub database attribute data in memory by configuring the attribute with fast-access. Having fast-access will load the attribute data of the stored copies into memory, making updates faster.
Sizing attribute memory
Attribute data can consume a lot of memory, especially when using fast-access, where not ready copies are brought into memory. Please see attribute memory usage sizing.