简体   繁体   中英

sql not executing properly

I have two sql files: The first one creates database, tables, and stored procedures. The second populates created tables with 90000 entries.

The creating sql file creates a total of 1 database, 26 tables and 104 stored procedures. The populate sql file adds 90000 entries.

For some reason when I execute the create file it works perfectly every time.

When I execute the populate file it works halfway. It populates half the tables, and the other half will stay empty. I noticed if I wait around 2 minutes after executing the create file and then try to execute the populate file then it works perfectly. Why is it doing that? Is there no way to populate tables very quickly without having to wait?

I am using the latest version of mysql and I have tried executing contents of the populate file via phpmyadming, and that yielded the same results.

I have to assume that the file that creates database and tables also create PRIMARY KEYS and Indexes . Have you considered splitting the files up into:

  1. Create Database and Tables
  2. Load Data
  3. Create Primary Keys and Indexes
  4. Create Stored Procedures.

As was also suggested try increasing the bulk_insert_buffer_size and change the way you insert from a single query as you posted to:

INSERT INTO faults(id, fault_name) VALUES (...), (...) ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM