有人能详细解释Magentos Indexing功能吗? [英] Can someone explain Magentos Indexing feature in detail?

查看:225
本文介绍了有人能详细解释Magentos Indexing功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到如何在Magento索引工作,但我没有看到任何好的文档。




  • 如何运作


  • 为什么很重要

  • 每个人都应该了解的细节是什么

  • 帮助某人完全理解索引是什么,以及如何在Magento中使用



我认为有此信息将对其他人有很大的帮助我的船没有完全获得索引过程。



更新:
在我的问题和Ankur的回答的评论后,我想我错过了在我的知识只是正常的数据库索引。所以这只是Magento的处理索引的版本,它是更好的我得到我的答案在数据库索引一般,如这里的链接数据库索引如何工作?

解决方案

Magento的索引只是类似到数据库级索引的精神。正如安东所说,它是一个反规范化的过程,允许一个站点的更快的操作。让我尝试解释一下Magento数据库结构背后的一些想法,以及为什么它使索引需要快速操作。



在一个更典型的MySQL数据库中,用于存储目录产品的表将构造成如下:

 产品:
product_id INT
sku VARCHAR
name VARCHAR
size VARCHAR
longdesc VARCHAR
shortdesc VARCHAR
... etc ...

这对于检索来说很快,但它对于一个电子商务软件留下了一个根本的问题:当你想添加更多的属性时,你做什么?如果你卖玩具,而不是尺寸栏,你需要 age_range 吗?好吧,你可以添加另一列,但是应该清楚,在大型商店(例如,沃尔玛),这将导致90%的行空,并试图维护新的属性是不可能的。



为了解决这个问题,Magento将表分成更小的单位。我不想在此答案中重新创建整个EAV系统,因此请接受此简化模型:

 产品:
product_id INT
sku VARCHAR

PRODUCT_ATTRIBUTE_VALUES
product_id INT
attribute_id INT
值MISC

PRODUCT_ATTRIBUTES
attribute_id
name

现在可以随意添加属性,方法是在 product_attributes ,然后将相邻的记录放入 product_attribute_values 中。这基本上是Magento做的(更多地尊重数据类型比我在这里显示)。事实上,现在没有理由让两个产品具有完全相同的字段,因此我们可以使用不同的属性集创建整个产品类型



<然而,这种灵活性是有代价的。如果我想在我的系统中找到一个衬衫的颜色(一个简单的例子),我需要找到:


  1. 项目的 product_id (在产品表格中)

  2. c> c> $ > value (在attribute_values表中)

Magento习惯这样工作, 。因此,为了获得更好的性能,他们做出了妥协:一旦店主已经定义了他们想要的属性,就从头开始生成大表。当一些东西发生变化时,将它从空间中删除并重新生成。这样,数据主要以我们的灵活格式存储,但是从单个表中查询。



这些产生的查找表是Magento的索引。当你重新索引时,你会吹起旧表并再次产生。



希望澄清一下。



谢谢,
Joe


I kind of get how the indexing in Magento works, but I haven't seen any good documentation on this. I would kind of like to know the following.

  • How it works
  • What is its purpose
  • Why is it important
  • What are the details everyone should know about it
  • Anything else that can help someone fully understand what indexing is and how it is used in Magento

I think having this information will be of great use for others in my boat that don't fully get the indexing process.

UPDATE: After the comment on my question and Ankur's answer, I am thinking I am missing something in my knowledge of just normal Database Indexing. So is this just Magento's version of handling indexing and is it better for me to get my answer in terms of Database indexing in general, such as this link here How does database indexing work?

解决方案

Magento's indexing is only similar to database-level indexing in spirit. As Anton states, it is a process of denormalization to allow faster operation of a site. Let me try to explain some of the thoughts behind the Magento database structure and why it makes indexing necessary to operate at speed.

In a more "typical" MySQL database, a table for storing catalog products would be structured something like this:

PRODUCT:
    product_id INT
    sku        VARCHAR
    name       VARCHAR
    size       VARCHAR
    longdesc   VARCHAR
    shortdesc  VARCHAR
    ... etc ...

This is fast for retrieval, but it leaves a fundamental problem for a piece of eCommerce software: what do you do when you want to add more attributes? What if you sell toys, and rather than a size column, you need age_range? Well, you could add another column, but it should be clear that in a large store (think Walmart, for instance), this would result in rows that are 90% empty and attempting to maintenance new attributes is nigh impossible.

To combat this problem, Magento splits tables into smaller units. I don't want to recreate the entire EAV system in this answer, so please accept this simplified model:

PRODUCT:
    product_id INT
    sku        VARCHAR

PRODUCT_ATTRIBUTE_VALUES
    product_id   INT
    attribute_id INT
    value        MISC

PRODUCT_ATTRIBUTES
    attribute_id
    name

Now it's possible to add attributes at will by entering new values into product_attributes and then putting adjoining records into product_attribute_values. This is basically what Magento does (with a little more respect for datatypes than I've displayed here). In fact, now there's no reason for two products to have identical fields at all, so we can create entire product types with different sets of attributes!

However, this flexibility comes at a cost. If I want to find the color of a shirt in my system (a trivial example), I need to find:

  1. The product_id of the item (in the product table)
  2. The attribute_id for color (in the attribute table)
  3. Finally, the actual value (in the attribute_values table)

Magento used to work like this, but it was dead slow. So, to allow better performance, they made a compromise: once the shop owner has defined the attributes they want, go ahead and generate the big table from the beginning. When something changes, nuke it from space and generate it over again. That way, data is stored primarily in our nice flexible format, but queried from a single table.

These resulting lookup tables are the Magento "indexes". When you re-index, you are blowing up the old table and generating it again.

Hope that clarifies things a bit!

Thanks, Joe

这篇关于有人能详细解释Magentos Indexing功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆