Skip to content

Conversation

@PetrHudik
Copy link

I've noticed some performance issues in v. 2.3.5, so I've written failing test. This test is passing in v. 2.3.4. This little bug kills my app really badly.

I don't underestant what is under the hood Nette/Database, I've spent a lot of time isolating this issue and this test explains is quite well.

Should I create an Issue? or is failing test enought?

@Unlink
Copy link
Contributor

Unlink commented Sep 7, 2015

I know, where a problem is.
It is caused by this commit 1c7eba6.
If you remove ->where('state', 'private') it works how you expected and 3 queries are used. But when you use where, limit, group..., it now clear also referenced cache.

I think, that it couldn't invalidate data, if query paramaters wasn't changed.
So it can be implement like this

public function limit($limit, $offset = NULL)
{
    $oldKey = $this->getSpecificCacheKey();
    $this->sqlBuilder->setLimit($limit, $offset);
    if ($oldKey != $this->getSpecificCacheKey()) {
        $this->emptyResultSet();
    }
    return $this;
}

or find another way, how to invalidate referenced data because in that case it also makes lot of queries

foreach ($context->table('book') as $book) {
    foreach ($book->related('book_tag_alt')->where('state', ($book->id % 2) ? 'private' : 'public') as $bookTag) {
        $tag = $bookTag->tag;
    }
}

But this is not good example, because before 1c7eba6 it also use 1 + n + 2 queries and now 1 + 2n

@Unlink
Copy link
Contributor

Unlink commented Sep 7, 2015

ping @Hajneej

@Hajneej
Copy link
Contributor

Hajneej commented Sep 8, 2015

@Unlink @PetrHudik send PR #92 solved by clearing cache only for root selection, not for GroupedSelection

@dg dg closed this in 4e1ec4c Sep 14, 2015
dg pushed a commit that referenced this pull request Sep 14, 2015
…roupedSelection), performance improvement [Closes #91][Closes #92]
dg pushed a commit that referenced this pull request Sep 14, 2015
…roupedSelection), performance improvement [Closes #91][Closes #92]
dg pushed a commit that referenced this pull request Sep 14, 2015
…roupedSelection), performance improvement [Closes #91][Closes #92]
dg pushed a commit that referenced this pull request Sep 14, 2015
…roupedSelection), performance improvement [Closes #91][Closes #92]
dg pushed a commit that referenced this pull request Sep 14, 2015
…roupedSelection), performance improvement [Closes #91][Closes #92]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants