This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Filtering from multiple object ID
expandshrink

Filtering from multiple object ID

Filtering from multiple object ID

Friday 23 November 2012 10:51:06 am - 5 replies

Hi everybody,

I'm trying to filter a fetch.

I've got a class which has an object relationS attribute. My filter allows to fetch objects of this class filtered by the object relations attribute.

I've started using the Enhanced Object Relations Filtering extension (http://projects.ez.no/index.php/enhanced_object_relation_filter), but this one only works with "AND" conditions and I want "OR".

I was able to edit the file to add the "OR" logic and this is what I got: https://gist.github.com/4134817

This extended attribute filter produces this string : 

eor_link_126.from_contentobject_id = ezcontentobject.id AND eor_link_126.from_contentobject_version = ezcontentobject.current_version AND eor_link_126.contentclassattribute_id = 537 AND eor_link_126.to_contentobject_id = 126 OR (eor_link_127.from_contentobject_id = ezcontentobject.id AND eor_link_127.from_contentobject_version = ezcontentobject.current_version AND eor_link_127.contentclassattribute_id = 537 AND eor_link_127.to_contentobject_id = 127 AND

I know it misses some parenthesis so I edited the string to test it directly in phpMyAdmin. This is the query: https://gist.github.com/4134811

The thing is, when I execute the query above, nothing is returned because the query never stops. The CPU hits 100% and I have to restart mysql which means it's not a syntax issue.

If anyone has any clue about this it will be very helpful.

Modified on Friday 23 November 2012 11:13:25 am by Antoine Descamps

Friday 23 November 2012 12:47:23 pm

How many records do you have in ezcontentobject_link table?

I tried a explain of your query in one of my databases. it showed that no key was used for eor_link_126 and eor_link_127 tables. and i think that this can be a real cause for your cpu problem. 

If would hardly recommed to go for a ezfind fetch query here, if possible...

Friday 23 November 2012 2:15:49 pm

Here is the result of the explain: http://imgur.com/QFz1r

And you're right, too much rows without any index :/

Should I add indexes or go with ezfind?

Modified on Monday 26 November 2012 3:54:25 pm by Antoine Descamps

Monday 26 November 2012 3:54:53 pm

I can't go with ezfind since the website is on a shared hosting, no Java, only PHP.

Tuesday 27 November 2012 10:17:26 am

Hi Antoine, 

The alternative would then be to break down the retrieval logic into simpler bits, that would not require the extended attribute filter. It will certainly take more code and a bit of additional memory, but will make your life way easier.

Cheers,

Friday 30 November 2012 2:57:49 pm

Quote from Nicolas Pastorino :

Hi Antoine, 

The alternative would then be to break down the retrieval logic into simpler bits, that would not require the extended attribute filter. It will certainly take more code and a bit of additional memory, but will make your life way easier.

Cheers,

Well, at first we were retrieving all the content of a given class and then filtering the given array, but it was way too much memory consuming. Page load time was about 20sec :/

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from