Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hashing VS Indexing

Both hashing and indexing are use to partition data on some pre- defined formula. But I am unable to understand the key difference between the two.

As in hashing we are dividing the data on the basis of some key value pair, similarly in Indexing also we are dividing data on some pre defined values.

Can any one please help me out the difference between Hashing and Indexing, and how to decide whether to use hashing or Indexing.

like image 892
coolDude Avatar asked Dec 16 '13 21:12

coolDude


People also ask

Does indexing use hashing?

Each key of the index contains only one row of the table data and uses the indexing algorithm called hashing which assigns them a unique location in memory, eliminating all other keys with duplicate values before finding what it's looking for. Hash indexes are one of many ways to organize data in a database.

What are the two types of indexing?

Clustered and non-clustered indexes This order is why only one clustered index can exist in any table, whereas, many non-clustered indexes can exist in the table. In some database systems, the leaf node of the clustered index corresponds to the actual data, not a pointer to data that is found elsewhere.

What do you mean by hashing give advantages of hashing over indexing?

Hashing technique is used to calculate the direct location of a data record on the disk without using index structure. In this technique, data is stored at the data blocks whose address is generated by using the hashing function. The memory location where these records are stored is known as data bucket or data blocks.


2 Answers

Hashing is a specific case of indexing:

Hashing vs. Indexing

Indexing is a general name for a process of partitioning intended at speeding up data look-ups. Indexing can partition the data set based on a value of a field or a combination of fields. It can also partition the data set based on a value of a function, called hash function, computed from the data in a field or a combination of fields. In this specific case, indexing is called data hashing.

like image 73
Sergey Kalinichenko Avatar answered Sep 27 '22 20:09

Sergey Kalinichenko


I did some research on web:

What is indexing?

Indexing is a way of sorting a number of records on multiple fields. Creating an index on a field in a table creates another data structure which holds the field value, and pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.

What is hashing?

Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value.

like image 26
coolDude Avatar answered Sep 27 '22 21:09

coolDude