Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accuracy of selecting element queries to execute #466

Closed
bencroker opened this issue Jan 31, 2023 · 1 comment
Closed

Improve accuracy of selecting element queries to execute #466

bencroker opened this issue Jan 31, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bencroker
Copy link
Collaborator

We could get more specific about which element queries need to be executed during a cache refresh, thus reducing the processing time. For example, entry queries are ordered by post date by default, meaning that if an entry is updated but its post date has not changed, then entry queries with an orderBy set to postDate can be ignored.

This applies to entry queries such as the following.

{% set entries = craft.entries.one() %}
{% set entries = craft.entries.orderBy('postDate DESC').all() %}
{% set entries = craft.entries.sectionId(1).orderBy('postDate ASC').all() %}

But not to the following, since they rely on attributes and custom fields.

{% set entries = craft.entries.title('Contact').one() %}
{% set entries = craft.entries.slug('contact').one() %}
{% set entries = craft.entries.myCustomField('myValue').all() %}

We could, however, make the same checks on attributes such as title, slug, dateCreated, etc.

@bencroker bencroker added the enhancement New feature or request label Jan 31, 2023
@bencroker bencroker added this to the 5.x milestone Jan 31, 2023
@bencroker bencroker self-assigned this Jan 31, 2023
@bencroker bencroker modified the milestones: 5.0, 4.x Feb 24, 2023
@bencroker
Copy link
Collaborator Author

bencroker commented Feb 24, 2023

As of version 4.4.0, Blitz automatically tracks which attributes and custom fields are used in each element query, as well as which attributes and custom fields are changed on each element save, greatly reducing the number of element queries that must be executed during the cache refresh process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant