Skip to content

Newsletter\Model\Subscriber::loadByEmail() does not use MySQL index #12787

@schmengler

Description

@schmengler

Preconditions

  1. Any Magento version between 1.0 and 2.2

Steps to reproduce

  1. Call $subscriber->loadByEmail($email) with debugger or profiler
  2. Inspect SQL query
  3. Inspect execution plan EXPLAIN SELECT * FROM newsletter_subscriber WHERE subscriber_email='...'

Expected result

  1. An index should be use to retrieve the subscriber instantly

Actual result

  1. No index is used, resulting in a slow "Using where" query like this:
+----+-------------+-----------------------+------+---------------+------+---------+------+-------+-------------+
| id | select_type | table                 | type | possible_keys | key  | key_len | ref  | rows  | Extra       |
+----+-------------+-----------------------+------+---------------+------+---------+------+-------+-------------+
|  1 | SIMPLE      | newsletter_subscriber | ALL  | NULL          | NULL | NULL    | NULL | 75735 | Using where |
+----+-------------+-----------------------+------+---------------+------+---------+------+-------+-------------+

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions