How to speed up MySql Like query ?

Created at: 2019-08-12 16:36:45 Updated at: 2019-08-12 16:37:06

in Database, MySql

For string columns, MySQL indexes the left side of a string. That means an index can speed a like query that has a wildcard on the right side:

SELECT * FROM users WHERE email LIKE "@gmail.com%"

This will be faster with an index column

Nested Set pattern for Laravel’s Eloquent ORM.

Created at: 2019-08-12 16:33:48 Updated at: 2019-08-12 16:35:03

in Algorithm, Laravel

For Nested Set pattern , I would suggest to follow this links

The theory behind, a TL;DR version

An easy way to visualize how a nested set works is to think of a parent entity surrounding all of its children, and its parent surrounding it, etc. So this tree:

root
  |_ Child 1
    |_ Child 1.1
    |_ Child 1.2
  |_ Child 2
    |_ Child 2.1
    |_ Child 2.2

Could be visualized like this:

 ___________________________________________________________________
|  Root                                                             |
|    ____________________________    ____________________________   |
| ...