Some rookie problems in the database

1
for example:
CREATE INDEX idx_user_username ON user (username (6));
idx_user_username is the name of the index, does this name need to be written or reflected in the program
or will the database itself do it without our management?

2
how to measure the retrieval speed after adding an index

Jan.08,2022

The

index generally does not need to display the specified index, but if you are not satisfied with the result of database automatic optimization, you can also specify to use the index
such as

.
select * from user force index (idx_user_username);

the most common way to view index usage is explain
such as

    explain select * from user force index (idx_user_username);

  1. what you create is an index for a field. After you create it, you don't need to worry about it, and the database itself will deal with it accordingly.
  2. it's easy to compare. You create two tables, table1 and table2, using the same table structure fields and inserting the same amount of data, but one table has an index for a certain field, and the other table does not have an index. Then query this field and compare the query results. No, no, no.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e483b9-44cb7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e483b9-44cb7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?