1

I've been using Craft for a couple of years now and I do love it, however I consistently run into massive performance issues with it. I heavily rely on caching and eager loading - however this doesn't help when building filters that query against relationships (i.e. 'categories' and 'entries' fields) as the number of combinations of returned content is too high to think about caching.

Craft 3 has been made significantly faster than Craft 2 according to the website, however that's ideal conditions presumably loading entries with no fields on them - because even with Craft 2 I've never got close to the numbers quoted in real world applications.

Have any improvements been made to the performance and overhead of searching related fields and categories?

Some people have suggested using Algolia, but I've built a solution that's worked around the issue. I'd just rather not have to go to such extremes.

Thanks! (and thanks in advance for your time - presumably Brad :P).


An example of the type of scenario I'm referencing is below:

# Get element criterea for searching projects
$projectCriterea = craft()->elements->getCriteria(ElementType::Entry);
$projectCriterea->section = 'projects';
$projectCriterea->order = $orderBy;
$projectCriterea->limit = $limit;
$projectCriterea->offset = $offset;

... etc ...

# Project categories i.e. bridges
$relatedProjectTypes = [
    'targetElement' => $projectCategories,
    'field' => 'portfolioCategories',
];            

# Location (New Zealand, Australia etc).
$relatedToLocations = [
    'targetElement' => $locationCategories,
    'field' => 'portfolioLocationCategories',
];  

... etc ...

$projectCriterea->relatedTo = ['and', $relatedToLocations, $relatedProjectTypes];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.