{"action":"created","issue":{"url":"https://api.github.com/repos/brianmario/mysql2/issues/623","labels_url":"https://api.github.com/repos/brianmario/mysql2/issues/623/labels{/name}","comments_url":"https://api.github.com/repos/brianmario/mysql2/issues/623/comments","events_url":"https://api.github.com/repos/brianmario/mysql2/issues/623/events","html_url":"https://github.com/brianmario/mysql2/issues/623","id":78570326,"number":623,"title":"Performance problems","user":{"login":"pmontrasio","id":47483,"avatar_url":"https://avatars.githubusercontent.com/u/47483?v=3","gravatar_id":"","url":"https://api.github.com/users/pmontrasio","html_url":"https://github.com/pmontrasio","followers_url":"https://api.github.com/users/pmontrasio/followers","following_url":"https://api.github.com/users/pmontrasio/following{/other_user}","gists_url":"https://api.github.com/users/pmontrasio/gists{/gist_id}","starred_url":"https://api.github.com/users/pmontrasio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmontrasio/subscriptions","organizations_url":"https://api.github.com/users/pmontrasio/orgs","repos_url":"https://api.github.com/users/pmontrasio/repos","events_url":"https://api.github.com/users/pmontrasio/events{/privacy}","received_events_url":"https://api.github.com/users/pmontrasio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-20T15:29:43Z","updated_at":"2015-05-20T16:05:02Z","closed_at":null,"body":"I had to move an application from PostgreSQL 9.4 to MariaDB 10 (customer choice). I'm using ActiveRecord but it's not a Rails app. I have a seeding script for the database. It creates 1.000 customers and some associated records using FactoryGirl. It runs in 1 minute 3\" with PostgreSQL and 21 minutes 47\" with MariaDB. It can't be the database (a 20x difference is impossible, I expect them to be reasonably matched). The database is running on Ubuntu 12.04 and the distribution's MySQL 5.5 is almost equally slow (16 minutes 23\"). Connecting through the UNIX domain socket or the network port doesn't change the times much. The distribution MySQL is probably fairly well configured so I'm looking at the adapter now.\r\n\r\nI installed the gem with the correct libraries \r\n\r\n    bundle config build.mysql2 --with-mysql-config=/path/to/mariadb/bin/mysql_config\r\n    bundle\r\n\r\nand I checked that mysql_config returns the path to the MariaDB libraries.\r\n\r\nThis is not the first time I've been using mysql2 and in the other projects I didn't notice anything strange. Even if I never matched MySQL against PostgreSQL (pg gem) I think I would have noticed such a slow database access.\r\n\r\nDid anybody had similar problems?"},"comment":{"url":"https://api.github.com/repos/brianmario/mysql2/issues/comments/103940821","html_url":"https://github.com/brianmario/mysql2/issues/623#issuecomment-103940821","issue_url":"https://api.github.com/repos/brianmario/mysql2/issues/623","id":103940821,"user":{"login":"sodabrew","id":39406,"avatar_url":"https://avatars.githubusercontent.com/u/39406?v=3","gravatar_id":"","url":"https://api.github.com/users/sodabrew","html_url":"https://github.com/sodabrew","followers_url":"https://api.github.com/users/sodabrew/followers","following_url":"https://api.github.com/users/sodabrew/following{/other_user}","gists_url":"https://api.github.com/users/sodabrew/gists{/gist_id}","starred_url":"https://api.github.com/users/sodabrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sodabrew/subscriptions","organizations_url":"https://api.github.com/users/sodabrew/orgs","repos_url":"https://api.github.com/users/sodabrew/repos","events_url":"https://api.github.com/users/sodabrew/events{/privacy}","received_events_url":"https://api.github.com/users/sodabrew/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T16:05:02Z","updated_at":"2015-05-20T16:05:02Z","body":"If you have a ruby profiler, look to see if there is a hot spot in code.\n\nLook for queries that may be locking the tables. This can cause slow behavior without obvious high cpu load. Because the query optimizers are very different between Pg and MySQL, these situations can occur on one db not the other.\n\nAs for database tuning, that's largely out of scope for this issue tracker, but here a a few ideas to kick start: for temp objects with unit tests, try using an in memory table type. For bulk inserts, do them all inside a single transaction. Make sure there is enough innodb log space, otherwise the transaction journal has to be flushed too often. Make sure there is enough innodb buffer pool - I've seen distribution defaults as low as 8MB when a good value might be 2GB.\n"}}