New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dbWriteTable() much slower than RMySQL, especially slow on Mac #125
Comments
|
Thanks for the detailed benchmark. It strikes me odd that writing times are much much lower for RMySQL than its reading times. This can happen if data is written asynchronously. @jeroen: Any ideas? |
|
Sounds similar to #104 |
|
Confirming huge performance difference between RMySQL and RMariaDB |
|
@rspreafico-vir Can you elaborate on your setup? Where is your database located (e.g. Google Cloud)? Are you on a mac? Thx |
|
Yes, I am connecting from a Mac to an AWS RDS hosted MySQL database. C connector installed. Used RMariaDB to write ~3 million rows, never terminated. In a for loop, ~1,000 rows at a time, would take 2 min for each cycle. With RMySQL, in 5 min all 3 million rows had been written. |
|
Could be linked to the generation of the SQL strings rather than really execution time. Creating large strings can be expensive. The |
This comment has been minimized.
This comment has been minimized.
|
fyi I've found it's much faster to write a file to disk and then use dbWriteTable on the file, rather than using a data.frame as the input to dbWriteTable. I believe this has something to do with chunking: dbWriteTable will append rows one line at a time when using a data.frame input, but will batch add lines when using a file input. I could be wrong though--it's been over a year since I looked into this. |
|
Planning to release an update that uses |
RMySQL is orders of magnitude faster than RMariaDB, especially for writes. Tested on both OSX and Amazon Linux. Reading/writing from an AWS RDS database, MySQL v5.6.39. Also Amazon Linux is much faster than Mac, although I guess that could be a product of network speed. That is also a concern because we do some development on Macs. The reason I don't just switch to RMySQL is that RMariaDB handles unicode characters better than RMySQL, which is another important consideration.
Script
There is a
DBI::dbWriteTable()andDBI::dbConnect()in addition toRMariaDB::dbWriteTable()andRMariaDB::dbConnect(). To avoid any namespacing confusion, I ran everything with every combination of DBI, RMySQL, and RMariaDB.Before running I uninstalled and reinstalled R packages.
I also installed
mariadb-develandmysql-develon Linux andmariadb-connector-candmysql-connector-con Mac.Amazon Linux Output
RMySQL queries are 1.2x to 3x faster than RMariaDB
RMySQL writes are 10x to 25x faster than RMariaDB
$ yum list | grep maria mariadb-devel.x86_64 1:5.5.60-1.amzn2 @amzn2-core mariadb-libs.x86_64 1:5.5.60-1.amzn2 installed mariadb.x86_64 1:5.5.60-1.amzn2 amzn2-core mariadb-bench.x86_64 1:5.5.60-1.amzn2 amzn2-core mariadb-embedded.x86_64 1:5.5.60-1.amzn2 amzn2-core mariadb-embedded-devel.x86_64 1:5.5.60-1.amzn2 amzn2-core mariadb-libs.i686 1:5.5.60-1.amzn2 amzn2-core mariadb-server.x86_64 1:5.5.60-1.amzn2 amzn2-core mariadb-test.x86_64 1:5.5.60-1.amzn2 amzn2-core$ yum list | grep mysql apr-util-mysql.x86_64 1.6.1-5.amzn2.0.2 amzn2-core dovecot-mysql.x86_64 1:2.2.10-8.amzn2.0.2 amzn2-core freeradius-mysql.x86_64 3.0.13-9.amzn2 amzn2-core libdbi-dbd-mysql.x86_64 0.8.3-16.amzn2.0.1 amzn2-core mysql-connector-java.noarch 1:5.1.25-3.amzn2 amzn2-core mysql-connector-odbc.x86_64 5.2.5-7.amzn2 amzn2-core pcp-pmda-mysql.x86_64 3.12.2-5.amzn2 amzn2-core php-mysql.x86_64 5.4.16-43.amzn2 amzn2-core php-mysqlnd.x86_64 5.4.16-45.amzn2.0.6 amzn2-core qt-mysql.i686 1:4.8.5-15.amzn2.0.3 amzn2-core qt-mysql.x86_64 1:4.8.5-15.amzn2.0.3 amzn2-core qt5-qtbase-mysql.i686 5.9.2-3.amzn2.0.1 amzn2-core qt5-qtbase-mysql.x86_64 5.9.2-3.amzn2.0.1 amzn2-core redland-mysql.x86_64 1.0.16-6.amzn2.0.1 amzn2-core rsyslog-mysql.x86_64 8.24.0-16.amzn2.6.1 amzn2-coreOSX Output
RMySQL queries are similar to RMariaDB
RMySQL writes are 100x to 200x faster than RMariaDB
The text was updated successfully, but these errors were encountered: