Allow session garbage collection to use an index #6110

Merged
merged 1 commit into from Apr 14, 2014

Projects

None yet

3 participants

@hjr3

Performing arithmetic in the where clause prevents MySQL from using an index. The garbage collection becomes increasingly more expensive to run as traffic grows.

@hjr3 hjr3 Allow session garbage collection to use an index
Performing arithmetic in the where clause prevents MySQL from using an index. The garbage collection becomes increasingly more expensive to run as traffic grows.
eaecf25
@Ocramius Ocramius commented on the diff Apr 8, 2014
library/Zend/Session/SaveHandler/DbTableGateway.php
@@ -164,10 +164,9 @@ public function destroy($id)
public function gc($maxlifetime)
{
$platform = $this->tableGateway->getAdapter()->getPlatform();
- return (bool) $this->tableGateway->delete(sprintf('%s + %s < %d',
+ return (bool) $this->tableGateway->delete(sprintf('%s < %d',
@Ocramius
Ocramius Apr 8, 2014

Does mysql really not optimize this?

@hjr3
hjr3 Apr 8, 2014

No, I can provide a sql fiddle to prove it.

@Ocramius
Ocramius Apr 8, 2014

@hjr3 it's fine - I was really just wondering why MySQL always manages to disappoint me :D

@weierophinney weierophinney added this to the 2.3.1 milestone Apr 14, 2014
@weierophinney weierophinney self-assigned this Apr 14, 2014
@weierophinney weierophinney added a commit that referenced this pull request Apr 14, 2014
@weierophinney weierophinney Merge branch 'hotfix/6110' into develop
Forward port #6110
bfcee97
@weierophinney weierophinney merged commit eaecf25 into zendframework:master Apr 14, 2014

1 check passed

Details continuous-integration/travis-ci The Travis CI build passed
@weierophinney weierophinney added a commit that referenced this pull request Apr 14, 2014
@weierophinney weierophinney Merge branch 'hotfix/6110'
Close #6110
cf271e6
@hjr3 hjr3 deleted the hjr3:patch-1 branch Apr 16, 2014
@weierophinney weierophinney added a commit to zendframework/zend-session that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge pull request zendframework/zendframework#6110 from hjr3/patch-1
Allow session garbage collection to use an index
ddf2b3b
@weierophinney weierophinney added a commit to zendframework/zend-session that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/6110' 63fdbea
@weierophinney weierophinney added a commit to zendframework/zend-session that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/6110' into develop 5e70318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment