# B-tree

B-tree is the balanced tree access method that D3 supports
throughout the system and in every process that touches the database.

A B-tree is essentially a system-maintained ordered-list
based on any attribute or combination of attributes from items in
a file. It allows quick retrieval of items based on this secondary
key.

With minor modifications, current D3 applications can make
use of B-trees. Any D3 process that modifies an item automatically
maintains the tree implicitly. This includes update, FlashBASIC, edit, copy, t-load, and restore.

AQL retrieves
keys from a B-tree when an associated attribute-defining item is used
in a by clause.

For example, in the statement:

```
sort entity by last.name
```
last.name points to an attribute that
is also referenced by an i (index) processing code
in the attribute defining item. If more than one by clause is used in the same request, AQL ignores the tree and scans
the entire file. A with clause with no by clause also uses the tree.

A more flexible approach
to incorporating B-trees to data retrieval is to use the Update processor
or the FlashBASIC intrinsic functions like key and root.

## See also

- [a (algebraic) processing code](https://d3codex.com/processingcodes/a-algebraic-processing-code/)
- [Access Query Language](https://d3codex.com/access/access-query-language/)
- [by modifier](https://d3codex.com/access/by-modifier/)
- [create-index command](https://d3codex.com/tcl/create-index-command/)
- [delete-index command](https://d3codex.com/tcl/delete-index-command/)
- [i (local index) processing code](https://d3codex.com/processingcodes/i-local-index-processing-code/)
- [indexer command](https://d3codex.com/tcl/indexer-command/)
- [nframe-index command](https://d3codex.com/tcl/nframe-index-command/)
- [root statement](https://d3codex.com/pickbasic-flashbasic/root-statement/)
- [verify-index command](https://d3codex.com/tcl/verify-index-command/)

---
Source: https://d3codex.com/definitions/b-tree/ - part of the D3Codex reference.
