Skip to content

Conversation

@Hajneej
Copy link
Contributor

@Hajneej Hajneej commented Sep 8, 2015

Selection: referenced cache cleared only for root selection (not in GroupedSelection), performance improvment

solves #91

@Hajneej Hajneej mentioned this pull request Sep 8, 2015
@Hajneej Hajneej force-pushed the referenced-cache-performance branch from 2fcb211 to 35870aa Compare September 11, 2015 08:55
@Hajneej
Copy link
Contributor Author

Hajneej commented Sep 11, 2015

ping @hrach - refactor to more clean version

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place $this->refCache['referenced'] = []; here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running line $this->refCache['referenced'] = []; for GroupedSelection was actually the problem that i am trying to solve. This will actually break the query.count.phpt test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my previous comment, which I deleted yesterday?, was wrong. I misread the code. The previous version was probably better :| I really sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the iteration in iteration. The deleting referencedCache is launched for each inner interation. This leads to increasing number of sent queries (from 3 to 5 in query.count.phpt)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any difference between your code and this solution:

class GroupedSelection

protected function emptyResultSet(..) 
{
  parent::emptyResultSet($saveCache);
  $this->refCache['referenced'] = [];
}

Where is a difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Difference:

  1. My solution:
    When emptyResultSet() is called on Selection, the $this->refCache['referenced'] = []; line is executed. (the default value of second parameter is true)

When emptyResultSet() is called on GroupedSelection, the $this->refCache['referenced'] = []; is not executed (the second parameter of emptyResultSet is false)

  1. Your solution
    Its actually the opposite version of mine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to @hrach no problem :) i kind of prefer the previous version too. I was actually quite thinking about the realisation of what you thought

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, now I see. So what about

$old = $this->refCache['referenced'];
parent::emptyResultSet($saveCache);
$this->refCache['referenced'] = $old;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason of adding a parameter was that i was thinking e.g. about adding new descendant of Selection. Than this behaviour will be probably shared so i choose a parameter.

But i am completely fine with your solution too, if this is not an issue.

@Hajneej Hajneej force-pushed the referenced-cache-performance branch from 35870aa to 589ff75 Compare September 11, 2015 09:19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoud be FALSE

@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.

4 participants