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

你。 提交于 2019-11-28 06:58:38

Anything using pivot or aggregates will probably be faster, as they don't require the table to be self-joined. The join based approaches will require the optimiser to perform several sub-query operations and then join the results together. For a small data set this might not matter so much, but this could significantly degrade performance if you're doing an analytic query on a larger data set,

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!