M
M
MUTOgen4eg2013-11-26 22:40:06
Yii
MUTOgen4eg, 2013-11-26 22:40:06

Yii, EAV, performance?

Goodnight.
Faced such a question. There is some pretty heavy processing of entities on a Yii-based site.
I will briefly describe the essence: there are products that have custom modifications (for example, 8GB and 16GB phones, only the actual parameters can be different + for one product there can be several interrelated parameters and the number of values ​​\u200b\u200bmay differ).
Now there is one variable parameter on the products (on average, each product has 5-7 variations). All this is implemented through EAV.
The problem is that performance is not entirely satisfactory. 1 category page = 17 products, which takes 3.5-3.7 seconds on the server. Profiling the code and queries shows that it takes about 2 seconds to call the type (it is repeated 141 times on one page):

$attribute = Attribute::model()->with('options')->findByAttributes(array('name'=>$attr));

Logic suggests using caching, even if it's short-lived, but adding ->cache(120) does nothing. I'm afraid the further it goes (I mean several variable parameters for a product), the worse it will be.
Which direction should be taken to address this issue?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2013-11-26
@MUTOgen4eg

are you using this thing? Just throw out and rewrite with inner/left joins for selects.

M
Masterme, 2013-11-26
@Masterme

Are you doing requests in a loop?

_
_ _, 2013-11-26
@AMar4enko

When working with a database, there should be nothing implicit - you should fully understand how this or the ActiveRecord call works.
I developed a store in Yii, products with variable parameters, parameters in a separate table, a many-to-many relationship - everything ran fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question