“This is the 7th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

A simple query

Select * from table_name (select * from table_name, select * from table_name)

One thing to note is that in daily development, the use of * in SQL is highly discouraged for two reasons:

  1. If the table has a field expansion, inmapperThe layer needs to add corresponding field mappings, even if they are not actually used in that SQL
  2. *The order of the queried fields is based on the order in which the fields in the table are created. If the fields are adjusted, or new fields are inserted in places other than the end of the table, this will affectmapperThe mapping of
  3. A more practical question is the use*Queries all slow down THE execution of SQL, and becausemybaitsRedundant fields are mapped. This operation also has a performance penalty

There’s no proof. Take the data I have as an example:

There are 23 fields and the total number of records is 37000

Perform several select * operations first

The query takes about 0.29 seconds

Taking the example of several fields necessary for our query, four fields, taking about 0.1s, the performance will indeed be greatly improved by comparison

The sorting

In our regular table design, using the table increment primary key + system time, the queried data defaults to the insertion order, which looks like an ascending order of ID, and an ascending order of creation time

This sort of arrangement works in general. However, when the user focuses on the SPARator_line column, the data becomes cluttered, and we need to manually specify which fields and how to sort

Sort statement; Order by column [ASC]. There are two kinds of sorting, one is ascending ASC, do not display the specified default to this; The other is to display the specified descending order DESC

Sometimes there is a need for multi-field sorting, such as sorting data in descending order by field 2 for the same value in field 1 in ascending order. If you still need to sort by field 3, sort the data with the same value in field 2 based on the sorting in the previous step. To separate multiple sort conditions, use

For example, the data is in ascending order by SPARator_line and then in descending order by time