Nonexistent values are not cached with field=myfield
, causing unneeded SQL queries
#1970
Labels
field=myfield
, causing unneeded SQL queries
#1970
Short description of the issue
If I loop pages fetched with
find("template=$template, field=mytext")
, calling$page->mytext
makes a database query for each page that do not havemytext
value. This causes an "N+1 queries problem", potentially making a lot of unneeded queries.Expected behavior
field=mytext
should cache both the value and absence of a value, and no further database queries is needed when$page->mytext
is accessed.Actual behavior
For each page without
mytext
,$page->mytext
triggers the queryOptional: Suggestion for a possible fix
I suspect this to be a regression of processwire/processwire@4344df3.
I believe the code should read:
Steps to reproduce the issue
mytext
tobasic-page
mytext
for one pagemytext
.Setup/Environment
The text was updated successfully, but these errors were encountered: