Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow session garbage collection to use an index #6110

Merged
merged 1 commit into from

3 participants

Herman J. Radtke III Marco Pivetta Matthew Weier O'Phinney
Herman J. Radtke III

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

Herman J. Radtke III 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
Marco Pivetta Ocramius commented on the diff
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',
Marco Pivetta Collaborator
Ocramius added a note

Does mysql really not optimize this?

Herman J. Radtke III
hjr3 added a note

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

Marco Pivetta Collaborator
Ocramius added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Matthew Weier O'Phinney weierophinney added this to the 2.3.1 milestone
Matthew Weier O'Phinney weierophinney self-assigned this
Matthew Weier O'Phinney weierophinney merged commit eaecf25 into from
Matthew Weier O'Phinney weierophinney referenced this pull request from a commit
Matthew Weier O'Phinney weierophinney Merge branch 'hotfix/6110'
Close #6110
cf271e6
Herman J. Radtke III hjr3 deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 8, 2014
  1. Herman J. Radtke III

    Allow session garbage collection to use an index

    hjr3 authored
    Performing arithmetic in the where clause prevents MySQL from using an index. The garbage collection becomes increasingly more expensive to run as traffic grows.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 3 deletions.
  1. +2 −3 library/Zend/Session/SaveHandler/DbTableGateway.php
5 library/Zend/Session/SaveHandler/DbTableGateway.php
View
@@ -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',
Marco Pivetta Collaborator
Ocramius added a note

Does mysql really not optimize this?

Herman J. Radtke III
hjr3 added a note

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

Marco Pivetta Collaborator
Ocramius added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
$platform->quoteIdentifier($this->options->getModifiedColumn()),
- $platform->quoteIdentifier($this->options->getLifetimeColumn()),
- time()
+ (time() - $this->lifetime)
));
}
}
Something went wrong with that request. Please try again.