Range query

from Wikipedia, the free encyclopedia

A range query (engl .: range query ) is a conventional database query , all of which records (rows in the database table of a relational database locates) in which a particular attribute within a predetermined interval is. Area queries are unusual because it is not known in advance whether and how many entries will be returned. Many other queries, for example for the ten oldest employees or the newest employee of a company, can be carried out more efficiently because the number of entries returned is limited.

Examples

  • All employees who have more than ten years of professional experience.
  • All products whose price is between 10 and 100 euros.

optimization

With a database index on the corresponding attribute, the searched data records can be determined without performing a sequential search (scan) on the entire table. A clustering of the table relative to the corresponding attribute in the mass storage also allows that only the addresses of the two sets of data have to be determined that the interval limits represent (via database index), and then all relevant records can be read sequentially. Clustering reduces the access time of a hard disk ; it hardly plays a role with SSDs . Both optimizations are fulfilled by a clustered index .