A method of retrieving data from an electronic database or information retrieval system by performing an electronic database or information retrieval system query, wherein the electronic database or information retrieval system query is a range query, the method comprising the steps of: obtaining the definitions of one or more ranges; and obtaining two or more input tries (3901; 3902); combining the input tries using a logical operation to obtain the set of keys associated with the nodes of a resulting trie; and providing as query output the set of keys associated with the nodes of the resulting trie, or a subset of the keys associated with the nodes of the resulting trie, in particular the keys associated with the leaves of the resulting trie, or a set of keys or values derived from the keys associated with the nodes of the resulting trie; wherein a trie comprises one or more nodes, each child node is associated with a key portion, and the path from the root node to another node in the trie defines a key with which the node is associated, the key being a concatenation of the key portions associated with the nodes on the path; wherein the set of child nodes of each node in the resulting trie is the combination, using the logical operation, of the sets of child nodes of the corresponding nodes in the input tries; and two or more nodes of different tries correspond to each other if the keys associated with the nodes of the different tries are identical; and wherein one input trie is an input set trie which stores a set of keys stored in the electronic database or information retrieval system or a set of result keys of an electronic database or information retrieval system query, to be searched for the one or more ranges, another input trie is a virtual range trie, wherein a range trie is a trie which when fully materialized stores all the values included in the one or more ranges of which the definitions have been obtained and the logical operation is an intersection, wherein a virtual range trie is a range trie which is dynamically generated during the operation of combining the input tries wherein those parts of the virtual trie are dynamically generated which are required for traversing the range trie. obtaining the definitions of one or more ranges; and obtaining two or more input tries (3901; 3902); combining the input tries using a logical operation to obtain the set of keys associated with the nodes of a resulting trie; and providing as query output the set of keys associated with the nodes of the resulting trie, or a subset of the keys associated with the nodes of the resulting trie, in particular the keys associated with the leaves of the resulting trie, or a set of keys or values derived from the keys associated with the nodes of the resulting trie; wherein a trie comprises one or more nodes, each child node is associated with a key portion, and the path from the root node to another node in the trie defines a key with which the node is associated, the key being a concatenation of the key portions associated with the nodes on the path; wherein the set of child nodes of each node in the resulting trie is the combination, using the logical operation, of the sets of child nodes of the corresponding nodes in the input tries; and two or more nodes of different tries correspond to each other if the keys associated with the nodes of the different tries are identical; and wherein one input trie is an input set trie which stores a set of keys stored in the electronic database or information retrieval system or a set of result keys of an electronic database or information retrieval system query, to be searched for the one or more ranges, another input trie is a virtual range trie, wherein a range trie is a trie which when fully materialized stores all the values included in the one or more ranges of which the definitions have been obtained and the logical operation is an intersection, wherein a virtual range trie is a range trie which is dynamically generated during the operation of combining the input tries wherein those parts of the virtual trie are dynamically generated which are required for traversing the range trie.