The efficiency of JAVA excel Import

there are provinces, cities and autonomous regions in excel, and there are Chinese characters
such as
clipboard.png

clipboard.png

. If

is directly imported into the database, the Chinese characters are saved, and the four-level linkage cannot be done, so I wrote the method: first get the excel Chinese characters, then look up the corresponding codes through the Chinese characters, and then save them in the database

. < H2 > at this time, the problem arises. As soon as the amount of data is large, the import is very slow. The provinces, cities and regions of each piece of data have to find the corresponding code, and 200 pieces of data have to be imported for more than 10 minutes. Is there any great guidance on which aspects should be optimized < / H2 >
Mar.28,2021

debugging the printed code block first is time-consuming, locating the code that is really time-consuming. The guess is that it takes time to query sql when you query cascading relationships. Cascading data is put into memory and fetched from memory as soon as it is used. If the query sql is slow, optimize the sql. In short, locate the time-consuming code first.


first import the database, and then write SQL batch


add more provincial, city and county fields. When importing, you can first verify the province, city and county, then insert all of them into List, batch, and finally cascade update id


    .
  1. sql batch
  2. Import asynchronously to prevent users from waiting for import.
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-1b3e073-2c3f9.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-1b3e073-2c3f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?