Database Indexing: The Problem with LIKE Queries

preview_player
Показать описание
Database indexing is employed to make SELECT queries faster. But did you know that when using LIKE queries with a wildcard, MySQL will only take advantage of your database index in certain scenarios?
This is what we will explore in this mysql tutorial. This sql tutorial works on pretty much any DBMS including MySQL Server, Percona Server, MariaDB, or other database management systems (SQL Server, MongoDB, Oracle, Sybase, etc.)

The crux of everything is this:
Avoid putting the wildcard before a search string because that means that MySQL, its flavors like Percona Server or MariaDB and other database management systems can search for anything at the beginning of the string which is likely to make the search slower than it could be when big data sets are involved.

As far as MySQL is concerned, queries using wildcards can use the ""%"" or ""*"" parameters, depending on what kind of a database indexing technique is used.

SELECT * FROM [your_table] WHERE [your_column] LIKE 'string%'; is using the ""%"" parameter.
While sql queries using a fulltext SQL index will look like so:
SELECT * FROM [your_table] WHERE MATCH([your_column]) AGAINST (""string*"");

Those who are interested more about SQL indexes should watch the video we've made earlier on:

We've also made other videos about database performance issues, database performance tuning, and database performance testing.

#shorts #reels #database #mysql #development #web #webdeveloper
Рекомендации по теме
join shbcf.ru