What is best performance for Retrieving MySQL EAV results as Relational Table

前端 未结 2 2039
-上瘾入骨i
-上瘾入骨i 2020-12-08 22:45

I want to extract results from EAV (entity-attribute-value) tables, or more specifically entity-metadata tables (think like wordpress wp_posts and wp_post

2条回答
  •  [愿得一人]
    2020-12-08 23:08

    The best way to find out would be to test, off course. The answer may be different depending on the size of the dataset, the number of different meta-keys, their distribution (do all entities have values for all meta-keys? or only for a few of them?), the settings of your database server and possibly many other factors.

    If I were to guess, I'd say that the cost of the JOIN operations in option 2 would be smaller than the cost of GROUP BY and aggregate functions needed in options 1 and 3.

    So, I would expect to find Option 2 faster than 1 and 3.

    To measure Option 4, you'll have to consider more factors as the application may be in another server so the loads of the two (db and application) servers and the number of clients that will be requesting these results have to be taken into account.


    Sidenote: you need GROUP BY e.ID in options 1 and 3.

提交回复
热议问题