From 7e05835aa76645635ab6f1471c779adf4accb827 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 8 Feb 2019 20:16:52 +0100 Subject: stdlib: Add ETS docs about partially bound key traversal --- lib/stdlib/doc/src/ets.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/stdlib/doc/src/ets.xml') diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index ccccf7de88..622edc072e 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -188,6 +188,21 @@ is used to keep the table fixated during the entire traversal.

+

Traversals using match and select functions may not need to + scan the entire table depending on how the key is specified. A match + pattern with a fully bound key (without any match variables) will + optimize the operation to a single key lookup without any table traversal + at all. For ordered_set a partially bound key will limit the + traversal to only scan a subset of the table based on term order. A + partially bound key is either a list or a tuple with a prefix that is fully + bound. Example:

+
+1> T = ets:new(t,[ordered_set]), ets:insert(T, {"555-1234", "John Smith"}).
+true
+2> %% Efficient search of all with area code 555
+2> ets:match(T,{[$5,$5,$5,$- |'$1'],'$2'}).
+[["1234","John Smith"]]
+
-- cgit v1.2.3