sql-fundamentals icon indicating copy to clipboard operation
sql-fundamentals copied to clipboard

Mysql data can be 10x faster

Open cscortes opened this issue 6 years ago • 1 comments

Hi, love this database, but I noticed that it was taking way too long to load the data in mysql.
I know that an external fix would be to set autocommit = 0, but most people aren't thinking about this when then just try to import the database. A transparent fix is to place the sql in sql-fundamentals/sql/northwind_data.sql in a transaction like so:

START TRANSACTION; ... All the insert statements .... ... COMMIT;

That caused that all of the 600 000 statements in the data file to import in a minute or 2.

cscortes avatar Jun 28 '18 18:06 cscortes

can i know how long it was taking to get data form sql file. I was running by command in npm run db:setup:mysql and db:setup:pg, both are taking to long on importing data for me.

[edit] I am able to run postgres database; after looking into it. but i have kept sudo -u postgres before the script. https://gist.github.com/nikhilkuyya/31e0c7b7e7d2c51ccc9cea81d984f298. cannot explain why i did it . but my understanding is that postgres is normal user get assigned when installing postgres. so taught that scripts need authentication.

nikhilkuyya avatar Oct 08 '18 09:10 nikhilkuyya