tag:blogger.com,1999:blog-20434908.comments2008-07-23T17:08:35.257+03:00Rational RelationalShlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comBlogger73125tag:blogger.com,1999:blog-20434908.post-80446113413395971442008-07-23T12:29:00.000+03:002008-07-23T12:29:00.000+03:00Thank you very much for this command line :for PID...Thank you very much for this command line :<BR/><BR/>for PID in `mysql -u user -ppass -e "show processlist" | grep Sleep | cut -f1`<BR/>do<BR/>mysql -u user -ppass -e "kill $PID"<BR/>done<BR/><BR/>Before I did all manually, thank you !!<BR/><BR/>FatihaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-57744614296928790422008-07-12T17:53:00.000+03:002008-07-12T17:53:00.000+03:00Didn't get in-depth into what you've written here,...Didn't get in-depth into what you've written here, but regarding this:<BR/>There is probably some linux command that enables buffering the result in between the commands.<BR/><BR/>The pipe buffer in Linux, defined by the PIPE_SIZE constant, is 4K. It's hardcoded into the kernel. I guess you could solve this with a mediator, such as this (found through Google, didn't test):<BR/>http://www.glines.org/wiki/bfr<BR/><BR/>As a side note, turns out enlarging your pipe buffer does not improve performance:<BR/>http://ussg.iu.edu/hypermail/linux/kernel/0001.1/0401.htmlאיליהhttp://www.blogger.com/profile/11368142121604941022noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-20987630100934497902008-07-09T04:37:00.000+03:002008-07-09T04:37:00.000+03:00thanks, this is great!thanks, this is great!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-78393072508950337672008-06-29T20:52:00.000+03:002008-06-29T20:52:00.000+03:00no doubt great post, try sqlyog, it offers cool db...no doubt great post, try sqlyog, it offers cool db management tool & is under open source which has made backing up MySQL databases far easier than using the CLI interface. Its layout and UI is also a tremendous improvement over the Administrator GUI from MySQL AB themselves. i was suggested by few of my collegues. u should also go with this. highly recommendable.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-21328955075106756402008-06-19T11:59:00.000+03:002008-06-19T11:59:00.000+03:00I probably should.. It needs a bit of clean-up & e...I probably should.. It needs a bit of clean-up & error handling etc before that... <BR/><BR/>And thanks!<BR/>I've got your book here on my bookshelf at work, by the way :)Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-19598033400902701932008-06-18T18:03:00.000+03:002008-06-18T18:03:00.000+03:00Hi Shlomo! Feel free to add your code as a code s...Hi Shlomo! Feel free to add your code as a code snippet on forge.mysql.com!<BR/><BR/>good stuff!Jayhttp://jaypipes.myopenid.com/noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-18233635941586283212008-06-18T01:20:00.000+03:002008-06-18T01:20:00.000+03:00Another way to do it atomically for an entire data...Another way to do it atomically for an entire database is:<BR/><BR/>create database dummy_db;<BR/><BR/>for each table in db:<BR/>create table x_new like x;<BR/>..<BR/><BR/>rename table x to dummy_db.x_old, x_new to x,<BR/>y to dummy_db.y_old, y_new to y, <BR/>...;<BR/><BR/>drop database dummy_db;swanharthttp://swanhart.livejournal.com/noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-64851712082503170152008-06-18T00:42:00.000+03:002008-06-18T00:42:00.000+03:00Tomer: According to the manual, the mysqldump does...Tomer: According to the manual, the mysqldump does not buffer contents in memory by default, when dumping table data. There is a config option "--skip-quick" that enables buffering. Then again, that's only for table data, not for DDL. <BR/>That's an interesting point tho. It doesn't happen in reality (at least it didn't to me) but it could happen. There is probably some linux command that enables buffering the result in between the commands.<BR/>Using a temporary file is also an option though.<BR/><BR/>Tim: This is also a good point. I've wrote this script to truncate tables in a database that has no foreign keys at all, but a lot of tables. <BR/>Truncating a lot of interconnected tables could be a problem, since AFAIK you can't truncate a table when it has records pointing to it (you can only DELETE from it). I'll need to think of a solution for that case then. Maybe somehow find out who are child tables, and truncate them before others...Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-74203904544284110852008-06-18T00:16:00.000+03:002008-06-18T00:16:00.000+03:00Using FOREIGN KEYs also helps since the TRUNCATE o...Using FOREIGN KEYs also helps since the TRUNCATE on the parent table also nukes all the children.Tim Soderstromhttp://www.moocowproductions.org/noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-22164200067759110312008-06-17T22:50:00.000+03:002008-06-17T22:50:00.000+03:00If the mysql-dump command isn't buffered this coul...If the mysql-dump command isn't buffered this could cause <B>huge</B> problems (imagine the drop command executed by MySQL while the dump is still underway). This probably isn't a problem because the dump program loads all data before rendering the output, but it still seems needlessly risky to me. I'd split those into two separate commands.Tomer Gabelhttp://www.tomergabel.comnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-13766843281275431752008-06-17T01:48:00.000+03:002008-06-17T01:48:00.000+03:00תודה, אני מניח? :)תודה, אני מניח? :)Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-84153797097757747512008-06-16T23:57:00.000+03:002008-06-16T23:57:00.000+03:00שנייה פריימק, אז הבלוג הזה בעצם אומר שעכשיו אתה "מ...שנייה פריימק, אז הבלוג הזה בעצם אומר שעכשיו אתה "מומחה" כזה? :)<BR/><BR/>סתאאם, אחלה מאמרים!<BR/><BR/>חברך ל-"חוליית" ה-RDBMSAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-39577046315007101112008-06-13T20:18:00.000+03:002008-06-13T20:18:00.000+03:00There is a snippet on the Forge site that uses a S...There is a snippet on the Forge site that uses a Stored Proc & Cursor to kill long running queries (contributed by Matt Montegomery). To make this a fully automated query killer all you need to do is setup an Event :)<BR/><BR/>http://forge.mysql.com/tools/tool.php?id=106Seannoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-78830840121017662008-06-13T05:21:00.000+03:002008-06-13T05:21:00.000+03:00was not only ugly, but wrong... corrected:mysql -B...was not only ugly, but wrong... corrected:<BR/><BR/>mysql -B -e "SHOW FULL PROCESSLIST;"| tee /tmp/mysqlprocesslist`date "+%Y-%m-%dT%H:%M:%S"` | grep -Ewv "Sleep|INSERT|UPDATE|REPLACE|Binlog Dump|NULL|Command" | grep SELECT | sort -n -r -k 6 | head -n 100 | awk -F \\t '{print $1,$6}' | grep -v " [1-2][0-9]"$ | grep -v " [0-9]"$ | awk '{print $1}' | xargs | sed 's/ /,/g' | xargs mysqladmin killbradhttp://www.blogger.com/profile/15013103275992833014noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-42072516977088970292008-06-13T04:36:00.000+03:002008-06-13T04:36:00.000+03:00It's not pretty and it's only for the 'nix-minded,...It's not pretty and it's only for the 'nix-minded, but I've found this useful when caught in the precarious position of needing to kill a number of uncooperative selects (in the case below batches of longest running 100, running >=30s)...<BR/><BR/>mysql -B -e "SHOW FULL PROCESSLIST;"| tee /tmp/mysqlprocesslist`date "+%Y-%m-%dT%H:%M:%S"` | grep -Ewv "Sleep|INSERT|UPDATE|REPLACE|Binlog Dump|NULL|Command" | grep SELECT | sort -n -r -k 6 | head -n 100 | awk -F \\t '{print $1,$6}' | grep -v [1-2][0-9]$ | grep -v " [0-9]"$ | xargs mysqladmin killbradhttp://www.blogger.com/profile/15013103275992833014noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-86982909017472507172008-06-13T03:01:00.000+03:002008-06-13T03:01:00.000+03:00Anonymous: Yes, it actually is a new addition in 5...Anonymous: Yes, it actually is a new addition in 5.1. Look at this manual page, in both 5.0 and 5.1 versions:<BR/>http://dev.mysql.com/doc/refman/5.1/en/information-schema.html<BR/>http://dev.mysql.com/doc/refman/5.0/en/information-schema.html<BR/>There are a lot more tables in the new soon-to-be-GA-nearly-almost-no-critical-bugs version.<BR/><BR/>Sheeri: Well, nothing beats a good linux command line :) Unfortunately, If you're working with windows as your client side, most of these tools are not available by default.<BR/><BR/>Arjen: Yes, I agree. I've added the "Sleep" condition as just an example to emphasize the fact this is a regular table which can be queried against - maybe not the best example at that.Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-14436222716974486792008-06-13T02:35:00.000+03:002008-06-13T02:35:00.000+03:00The sleeping connections is just a bad example. It...The sleeping connections is just a bad example. It means either persistent connections have been used where they shouldn't have, or the app is behaving silly. Easy MySQL-side workaround for this is<BR/>SET GLOBAL wait_timeout=10;<BR/><BR/>No need to mess with scripts of any kind, anyway ;-)Arjenhttp://www.blogger.com/profile/10094246971103644167noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-85587278142691243182008-06-12T23:26:00.001+03:002008-06-12T23:26:00.001+03:00(that example is for killing queries in the Sleep ...(that example is for killing queries in the Sleep mode)Sheeri K. Cabralhttp://www.blogger.com/profile/13990877688502800403noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-27254358630190059142008-06-12T23:26:00.000+03:002008-06-12T23:26:00.000+03:00For older systems, you can always use the commandl...For older systems, you can always use the commandline, combining mysql -e "show processlist" with grep for filtering and cut for getting the processid. I've done this often, with a shell script like:<BR/><BR/>for PID in `mysql -u user -ppass -e "show processlist" | grep Sleep | cut -f1`<BR/>do<BR/>mysql -u user -ppass -e "kill $PID"<BR/>doneSheeri K. Cabralhttp://www.blogger.com/profile/13990877688502800403noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-15364196828196993502008-06-12T21:07:00.000+03:002008-06-12T21:07:00.000+03:00Is that exclusive to 5.1? I'm not seeing it in 5....Is that exclusive to 5.1? I'm not seeing it in 5.0.51a.<BR/><BR/>mysql> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;<BR/>ERROR 1109 (42S02): Unknown table 'PROCESSLIST' in information_schemaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-65387479999436479222008-06-01T20:18:00.000+03:002008-06-01T20:18:00.000+03:00It was only a minor version upgrade, actually, no ...It was only a minor version upgrade, actually, no code changes were needed.<BR/><BR/>For validation and testing, we have our wonderful QA department.Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-91250330894101698632008-06-01T13:59:00.000+03:002008-06-01T13:59:00.000+03:00So upgrading the database server was quick, how lo...So upgrading the database server was quick, how long did it take you to plan it and test your application against the new version?<BR/><BR/>What method did you use to validate that your queries would all work on the new version?<BR/><BR/>How many changes did you need to make in the application code?Mark Robsonhttp://www.blogger.com/profile/15864507044869250062noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-53383754860966417252008-04-27T11:50:00.000+03:002008-04-27T11:50:00.000+03:00The future is 6.0+, and it's all too far away... :...The future is 6.0+, and it's all too far away... :) <BR/>I'd use the built-in InnoDB for the mysql schema if I were to decide, but MySQL AB probably avoids depending on it internally due to the fact it's owned by Oracle.Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.comtag:blogger.com,1999:blog-20434908.post-5801783039196727972008-04-27T11:29:00.000+03:002008-04-27T11:29:00.000+03:00Hi again,MYISAM is the only built-in engine. In th...Hi again,<BR/>MYISAM is the only built-in engine. In the future MMARlA will be the standard engine.<BR/>Maria will offer ACID.<BR/>You are right about the locks , but probably you can poll using different lock names. For instance, every event puts its lock name includinga tx table. Or just when finishing inserting a row in a tx table.<BR/><BR/>AndreyAndrey Hristovmysql.comnoreply@blogger.comtag:blogger.com,1999:blog-20434908.post-63716322948339144322008-04-27T10:48:00.000+03:002008-04-27T10:48:00.000+03:00GET_LOCK() is a great tool, but I don't see how yo...GET_LOCK() is a great tool, but I don't see how you can use it in this case. Each connection can only get one lock. You can test for existence of many locks, but you can't assure the order in which the events started. What was your idea?<BR/><BR/>Regarding the non transactional nature: if you want to do something like:<BR/>START TRANSACTION;<BR/>CREATE event...<BR/>CREATE event...<BR/>COMMIT;<BR/>And you need to be certain all of the events were added, you can't. Moreover, since it's MyISAM, a crash in the middle of the event creation can even corrupt the table.<BR/><BR/>Honestly, I really don't understand why MySQL uses MyISAM for the meta-data database.Shlomo Priymakhttp://www.blogger.com/profile/08509735030020026930noreply@blogger.com