Today, in a table in SQL queries, the query takes at least 20 seconds, the data is 620000 rows, and the SQL statement is as follows:
Test one: Use ORDER BY
Simply query 0, 10 rows of data, time consuming 27.888s
Select A.id,a.county_id,a.county_name,a.town_id,a.town_name,a.village_id,a.village_name,b.province as Province_ Name,b.name as City_name from place a left join City B in A.city_id=b.code where a.id is isn't null order by A.VILLAGE_ID as C Limit 0, 10
Test two: Do not use ORDER by
Select A.id,a.county_id,a.county_name,a.town_id,a.town_name,a.village_id,a.village_name,b.province as Province_ Name,b.name as City_name from place a left join City B on A.city_id=b.code where a.id are not null limit 0, 10
Also query 0, 10 rows of data, time consuming 0.084s
The above is for reference only, more detailed optimization is needed when the data is larger
SQL Big Data query cautious with order by