?
avatar mbabker
mbabker
10 Mar 2017

For every field, a single query is issued to look up its value:

SELECT `value`
 FROM `#__fields_values`
 WHERE `field_id` = 25
 AND `context` = 'com_content.article'
 AND `item_id` = '318'

This article was in a context where 13 fields were available to it, and on a category view, so in essence it was issuing 13 lookup queries for each article.

This is not going to scale well.

avatar mbabker mbabker - open - 10 Mar 2017
avatar joomla-cms-bot joomla-cms-bot - change - 10 Mar 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 10 Mar 2017
avatar Bakual
Bakual - comment - 10 Mar 2017

Yep, that's indeed not going to scale well.
I think we should be able to drop the WHEREfield_id= 25 part and retrieve all values for a given context and item_id in one query and work from that (maybe using some cache).
Pinging @laoneo, what do you think?

avatar brianteeman
brianteeman - comment - 10 Mar 2017

It was commented before this code was ever committed that for every field you are adding a query. I was told it wasnt a real issue :(

avatar mbabker
mbabker - comment - 10 Mar 2017

Well it is. We ran into this on our company's dev site with a slightly misconfigured fields setup that resulted in 260 extra queries being run (and inherently the page being basically dead).

Fields is essentially unusable in a category view. That's my conclusion from today's experience.

avatar csthomas
csthomas - comment - 10 Mar 2017

Please remove fields from category/featured view. Otherwise joomla (outside tags) will have to load fields too.

avatar brianteeman
brianteeman - comment - 10 Mar 2017

i only say what I was told not what i believed to be true :)

avatar Bakual
Bakual - comment - 10 Mar 2017

Please remove fields from category/featured view.

And the next one will ask to add it again...
And even if you remove it you still have the issue with the single article view that each field is looked up individually, one query for each field.
If we can get it at least down to one per item, it should not be that bad in list views imho.
It could maybe be reduced to one per list, but that would likely mean loading and caching all values for a given context which certainly isn't ideal either.

avatar csthomas
csthomas - comment - 10 Mar 2017

Ca not we load all fields per article? And do not use fields in categories. I have to take a look in code.

avatar csthomas
csthomas - comment - 10 Mar 2017

About categories: maybe add some new parameter to menu item.
"Show fields": article view, category view, ...

avatar mbabker
mbabker - comment - 10 Mar 2017

It's not so much adding fields to categories, but our issue was we had fields assigned to a category and a category page that was rendering 20 articles. 1 value lookup for each field in each article that's being displayed adds up quickly.

It's tolerable on a single item view unless you're adding 100 fields (if you do you're doing it wrong). But any config that is adding more than ~50 queries is screwing things up.

avatar csthomas
csthomas - comment - 10 Mar 2017

I always mean fields for articles in category view.

avatar laoneo
laoneo - comment - 11 Mar 2017

As long as we don't have events which are triggered for multiple articles at once it will be difficult to solve. Another approach would be to integrate com_fields into the models and abandon the plugin approach.

avatar laoneo
laoneo - comment - 11 Mar 2017

Having a look on the code, some optimisation should be possible. Will make a pr later.

avatar infograf768
infograf768 - comment - 11 Mar 2017

Shall we consider this as a Release Blocker?

avatar laoneo
laoneo - comment - 11 Mar 2017

I think so.

avatar laoneo
laoneo - comment - 13 Mar 2017

Please test pr #14558. It reduces some queries to fetch the values of the fields.

avatar Bakual
Bakual - comment - 13 Mar 2017

Closing as we have a PR.

avatar Bakual Bakual - change - 13 Mar 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-03-13 19:59:09
Closed_By Bakual
avatar Bakual Bakual - close - 13 Mar 2017

Add a Comment

Login with GitHub to post a comment