User:ASarabadani (WMF)/Database for developers toolkit/How-to/Make queries against production

If you want to understand if how some data in production has been stored, you sometimes need to query the database directly. To find a bug, to make some analysis, or anything.


 * If your query doesn't need private information (e.g. user emails, checkuser data). You can query the cloud replicas using Quarry
 * You can also ssh into toolforge and do "sql enwiki", it is interactive.
 * If your query needs private data or it will take a very long time (they get killed after an hour in cloud). Use the analytics replicas.
 * If you need something from databases that serve live traffic. ssh into the mwmaint node (currently mwmaint1002.eqiad.wmnet) and run "sql enwiki".
 * Note: Do not run anything that would take long. It will cause issues.
 * Try "sql enwiki -h" for help to see how you can connect to misc databases (like externalstorage cluster) or specific database hosts (e.g. db1234).
 * You can also try connecting to a database in the stand-by datacenter. Look at our database tree to choose
 * If you need to write something to the production database or for any reason need data from the master. ssh into the mwmaint node (currently mwmaint1002.eqiad.wmnet) and run "sql enwiki --write".
 * Note: This is highly dangerous. Get any write queries you need to do checked with someone else. "!log" your queries (if doesn't include private data) in #wikimedia-operations pointing to the ticket. Any read query done must be as fast as possible. If unsure, ask data persistence team first.
 * This can be used in emergencies that for example all of Wikipedia is down because of a missing table but again, their use must be extremely rare.