mysqlsqldatabaseviewindexing

What is difference between INDEX and VIEW in MySQL


Which one is fast either Index or View both are used for optimization purpose both are implement on table's column so any one explain which one is more faster and what is difference between both of them and which scenario we use view and index.


Solution

  • VIEW

    INDEX

    ANALOGY:

    Suppose in a shop, assume you have multiple racks. Categorizing each rack based on the items saved is like creating an index. So, you would know where exactly to look for to find a particular item. This is indexing.

    In the same shop, you want to know multiple data, say, the Products, inventory, Sales data and stuff as a consolidated report, then it can be compared to a view.

    Hope this analogy explains when you have to use a view and when you have to use an index!