Profiling Stored Procedures in MySQL 5.7

With the changes to performance_schema in MySQL 5.7 Development Milestone Release it is now possible to analyze and profile the execution of stored programs. This is highly useful if you develop more complex stored procedures and try to find the bottlenecks. The "old" performance_schema up to MySQL 5.6 only reported a CALL statement with a runtime, but no information on statements that were executed WITHIN the stored procedure. Now let’s try this in the latest MySQL 5.7.6 DMR release. After creating some test table and a test stored procedure we need to activate the events_statements_history_long consumer, which is OFF by default:mysql> UPDATE setup_consumers SET ENABLED="YES"            WHERE NAME = "events_statements_history_long"; Then let’s call the stored procedure that we want to inspect:mysql> CALL test.massinsert(400,405); To avoid that we overwrite data from the events_statements_history_long table with the following queries, let’s deactivate that consumer ASAP. If you have some concurrent load running on your system, it may be wise to leverage the filter options in performance_schema like setup_actors and/or setup_objects.mysql> UPDATE setup_consumers SET ENABLED="NO"           WHERE NAME = "events_statements_history_long"; Next step is to find our CALL statement in the events_statements_history_long table:mysql> SELECT event_id,sql_text,               CONCAT(TIMER_WAIT/1000000000,"ms") AS time                  FROM events_statements_history_long        WHERE event_name="statement/sql/call_procedure"; +———-+——————————-+———–+ | event_id | sql_text                      | time      | +———-+——————————-+———–+ | 144      | call massinsert(100,105)      | 0.2090ms  | | 150      | call massinsert(100,105)      | 79.9659ms | | 421      | CALL test.massinsert(400,405) | 74.2078ms | +———-+——————————-+———–+ 3 rows in set (0,03 sec) You see: I tried this stored procedure three times. The one I want to inspect in detail is event_id 421. Let’s look at all nested statement events that came from 421: mysql> SELECT EVENT_NAME, SQL_TEXT, CONCAT(TIMER_WAIT/1000000000,"ms") AS time FROM events_statements_history_long WHERE nesting_event_id=421 ORDER BY event_id; +————————–+———————————–+———–+ | EVENT_NAME | SQL_TEXT | time | +————————–+———————————–+———–+ | statement/sp/stmt | SET @i = first | 0.0253ms | | statement/sp/stmt | SET @i = @i + 1 | 0.0155ms | | statement/sp/stmt | INSERT INTO a VALUES (@i,MD5(@i)) | 45.6425ms | | statement/sp/jump_if_not | NULL | 0.0311ms | | statement/sp/stmt | SET @i = @i + 1 | 0.0297ms | | statement/sp/stmt | INSERT INTO a VALUES (@i,MD5(@i)) | 4.9695ms | | statement/sp/jump_if_not | NULL | 0.0726ms | | statement/sp/stmt | SET @i = @i + 1 | 0.0365ms | | statement/sp/stmt | INSERT INTO a VALUES (@i,MD5(@i)) | 6.8518ms | | statement/sp/jump_if_not | NULL | 0.0343ms | | statement/sp/stmt | SET @i = @i + 1 | 0.0316ms | | statement/sp/stmt | INSERT INTO a VALUES (@i,MD5(@i)) | 9.9633ms | | statement/sp/jump_if_not | NULL | 0.0309ms | | statement/sp/stmt | SET @i = @i + 1 | 0.0274ms | | statement/sp/stmt | INSERT INTO a VALUES (@i,MD5(@i)) | 5.6235ms | | statement/sp/jump_if_not | NULL | 0.0308ms | +————————–+———————————–+———–+ 16 rows in set (0,06 sec)  Now we have the statements that were executed in the stored procedure "massinsert(400,405)" with their individual execution times and in order of execution. We have all other information available as well, not only execution time. We can access number of rows affected, sql error text, used algorithms, … All information that performance_schema offers for statement events. This is a great way to analyze your stored procedures. find the most costly statements and improve performance of your stored programs. That is really a great enhancement to performance_schema.
via Planet MySQL
Profiling Stored Procedures in MySQL 5.7

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

We kind of assumed this year on Game of Thrones was going to be as bitter and dark as graveyard-shift coffee. After all, it’s based on the two ugliest books, A Feast for Crows and A Dance With Dragons. But we saw the season premiere last night, and it’s even nastier. Here are our spoiler-free impressions.

So last night, they held the U.S. premiere of Game of Thrones season five here in San Francisco, and they showed the opening episode "The Wars to Come." We can’t reveal much about what happens in the episode — but suffice to say that it’s very much an hour of setting up new conflicts and new challenges.

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

There are about a dozen different storylines playing out in "The Wars to Come," and the thing they have in common is that pretty much everybody is in the depths of despair and misery. It’s very much the vibe you remember from A Feast For Crows, only possibly even worse.

At the same time, for the first time ever, nothing that happens in this episode felt like it came from the books. Not one scene felt like an adaptation of a book scene, although there were a few notes here and there that felt similar. Even the characters who’ve mostly followed their book trajectories, up to now, are doing something pretty new.

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

And significantly, some of the biggest conflicts being set up in this season opener are entirely different than the relationships those characters have in the books — and seem likely to play out in a whole new way.

But what really makes this season opener of Game of Thrones feel so dark, and so intense, is the way this show really captures the natural reactions of some of the characters to the horrors they’ve been through. There’s a really strong attention to detail in the way that all of these characters feel weighted down by the past, and changed by their disappointments and losses. The episode was full of little moments where I found myself thinking, "Oh, of course that’s how that person would feel at this point." Especially the characters who don’t get POV chapters in the books — but even some of the books’ POV characters have a more fleshed-out response, thanks to strong performances from the cast.

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

And that’s really the biggest thing I came away with after this episode. The cast, many of whom were in the audience watching it with us, are doing a phenomenal job of adding more dimensions to these characters. Especially Peter Dinklage, who’s never been more tragic and mordant, and just magnetic, than he is in this opening episode — Tyrion Lannister pretty much owns the episode, and the amount of emotion and humor that Dinklage manages to pack into his scenes is a thing of pure amazement. After the first episode, Tyrion’s storyline is the one I’m most desperate to see play out this season, too.

And from the gorgeous opening moments, the episode is jam-packed with brilliant visuals and beautifully staged scenes. There are some really ambitious scenes just in this setup-heavy episode, which are put together with a ton of care. Westeros and Essos have a sense of scale and place, more than ever.

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

In general, the theme of this season seems to be that everybody is falling apart. Even the characters who seem to form new alliances or stick together in the books seem to be on the outs as the new season begins. And the way things are set up in this opening episode, it seems as though everybody is going to be at everybody else’s throat, pretty much.

In fact, the main thing that would make the season opener hard to talk about — even if I could talk about spoilers — is the fact that it’s so jam-packed with storylines, and so much of it consists of setup. This has been true of almost every season opener since season two, but this time in particular it feels as though there are a million pieces on the board and the show is darting from place to place, trying to keep tabs on them all. And this may really be the year that Game of Thrones becomes so big and so diffuse that it stops having any sense of cohesiveness at all — although I’m cautiously optimistic, based on what we know about the season’s arc.

Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

Plus even though this episode is mostly just pieces being moved into place, it does have one really strong arc in it, which ends with a really powerful image — one which isn’t in the books, and which represents a cliffhanger I’m dying to see play out.


Contact the author at charliejane@io9.com.

via Gizmodo
Wow, Game Of Thrones Season 5 Is Even Darker Than We Expected

Are You Depressed? The Symptoms of Male Melancholy

So far we’ve discussed the history of depression, and explored its possible causes. Before we conclude this series next week with a guidebook on managing your melancholy, we of course need to stop to examine what depression actually looks like. How is it different from run-of-the-mill sadness, and how does it manifest itself, especially in […]


via The Art of Manliness
Are You Depressed? The Symptoms of Male Melancholy

Math explains the best way to shuffle a deck of cards and why

Math explains the best way to shuffle a deck of cards and why

Everyone who has played poker or even Go Fish knows the basics of shuffling cards. There’s the riffle shuffle (combining two halves of a decks and making a bridge), overhand shuffling (quickly splicing cards from the deck back into the deck) and regular ol’ mixing all the cards up on a table. Which way is the best?

Math can explain! In order to achieve the closest possible shuffle to a random order there could be in a deck of cards, you have to riffle shuffle 7 times. That’s a lot, right? Not really. In order to reach that same randomness with the overhand shuffle, you would have to do it 10,000 times. And if you wanted to mix the deck up on a table, you would have to keep mixing for a full minute.

So riffle shuffling 7 times is the best and most efficient way to truly randomize a deck of cards. The overhand shuffle might be the worst way (which is probably why you never see it happen in a casino) with the mixing method being effective but annoying.


SPLOID is delicious brain candy. Follow us on Facebook or Twitter.

via Gizmodo
Math explains the best way to shuffle a deck of cards and why

Mike Basich Goes Off-Grid in Style

At his peak, professional snowboarder Mike Basich was clocking $170,000 a year,
enough to get himself into a 4,000-square-foot house he ultimately discovered
he didn’t need. Now retired from competition, Basich spent five years building
himself more unusual digs: An off-grid stone and wood cabin less than 250
square feet, located on a 40-acre plot of land he purchased in the Sierra Nevada
mountains.

It took a long time to build as Basich did most of the work himself, sourcing the granite,
pine and Douglas Fir from the property itself. The "toilet" is
outdoors, absent even an outhouse; the electricity comes from solar; the water is snowmelt; the heat
comes from large south-facing windows.

Journalist Laura Ling took a closer look at Basich’s place for her web series "Going Off
Grid," and the episode went live last week:

If
Basich seems like an outlier to you, consider the stats Ling presents in "Going Off
Grid’s" description: "[We examine] how 180,000 Americans a year are
choosing to live entirely disconnected from our modern internet-focused world
in pursuit of a more sustainable, simple lifestyle." 


via Core77
Mike Basich Goes Off-Grid in Style

Five Best Price Tracking Tools

Five Best Price Tracking Tools

Figuring out the best time to buy something requires constant watch over ever-fluctuating online prices, and some knowledge of how prices have changed in the past. Luckily, you don’t have to figure it all out yourself—there are great tools to help you do it. This week we’re looking at five of the best that will let you know when it’s time to strike.

Earlier in the week we asked you which price tracking tools you turned to when you wanted to be sure you bought at the right time. We only have room for the top five, and here they are, in no particular order:

CamelCamelCamel

Five Best Price Tracking Tools

CamelCamelCamel is one of our favorite ways to get discounts and track prices on Amazon products. We’ve mentioned it in our guide to getting the best price when shopping online and how to automate your discounts for the best price. You can install the browser extension (Firefox, Safari, Chrome has been removed from the store although you may still be able to find it) to get access to the site’s features without leaving Amazon, or you can just copy and paste an Amazon link or product name at the web site. In every case, CamelCamelCamel shows you how the price of the item has gone up or down over time, how prices have changed through Amazon directly and through third-party sellers who list new and used items on Amazon. If you sign up for a free account, you can set up alerts so the site can notify you by email when the price of an item drops below a certain amount, whether you can get it used for a given price, or whether it’s at an all-time low and now is a good time to buy. You can even see previous historic highs and lows, and try to map out when the best time to strike really is.

Those of you who nominated CamelCamelCamel highlighted how useful it is for not just finding discounts and looking to see how price cycles fluctuate for specific types of items (like electronics, appliances, and more), but also bemoaned the fact that NewEgg banned them from tracking items listed in their store. You also mentioned the fact that their Chrome extension has gone missing from the Chrome Web Store, which is never a good sign. Even so, many of you pointed to how helpful the service and the site is, and supported it in the nomination round. You can read more in its nomination thread here.


SlickDeals Price Tracker

Five Best Price Tracking Tools

SlickDeals is well known for bringing you great, up-to-the-minute discounts, coupons, and other deals from around the web, but their web-based price tracker is also great for watching prices on just about any item on Amazon, and on several other popular shopping sites, like Newegg, Gamestop, IKEA, Buy.com, and others. This opens the door to tracking not just what you can get in one place, but making sure you’re getting the best deal even if you don’t buy your item at Amazon, or if you just want to track an item at Amazon, but also at other online stores that sell the same product. The service doesn’t give you detailed price history like some of the others in the roundup, but it will track the price of your item from when you create the alert going forward, and send you an email if the price drops below a threshold that you set. You can also return to the price tracker at any time, log in to your account, and see all of your tracked items on the same screen.

Those of you who nominated SlickDeals’ price tracker praised it for supporting so many stores, and for giving you a no-nonsense way to track prices. One of you mentioned that the email alerts, combined with a special label in Gmail, made it easy to collect your own price history, and make sure you’re notified if anything drops so low that you know you want to spring on it right away. However, others of you pointed out that the price tracker is in beta, and it’s not terribly good just yet—although it’s constantly evolving with the help of SlickDeals’ massive community. You can read more in its nomination thread here.


PriceZombie

PriceZombie prides itself on being a price tracker that also helps you do comparison shopping, so you can track prices and price histories while also making sure that the item you want to buy is actually the best option for you and your budget. PriceZombie, beyond being a webapp, has add-ons for Chrome, Firefox, and Safari, and supports items from multiple retailers, including Amazon, Newegg, Target, TigerDirect, Fry’s, IKEA, HomeDepot, and more. Like any good price tracker, if you type in a product name or a product URL at a supported store, you’ll see a complete price history (if the item is being actively tracked, and if not, it’ll start tracking it) so you can see if now is a good time to buy, or if the price was lower in the past. You’ll be able to tell at a glance if there’s a pattern, or the price is just trending downward—and you’ll be able to set up price alerts so you’re notified to new lows. The beauty of PriceZombie though is that while others stop with tracking, they go further: They’ll also show you live price drops, so you can see if an item drops in real time (especially useful for Gold Box or super-hot new items), and they’ll help you track price protection—meaning if you strike at a low price, you can get notified that the price has dropped again, with enough time to request a refund for the difference from the store you bought it from. The service will even sync your Amazon Wish List for you, and notify you if something on your wish list suddenly gets cheaper.

PriceZombie’s nomination thread was fun to watch, since the service earned more than a few first-time fans through it. Several of you noted that you hadn’t heard of it before, but looking at its features and how well the site works, you were tempted to try it out—and you were surprised at how useful it is. Others of you pointed out that you get to interact more with the historic price data (unlike some of the others in our roundup) so you can actually see where the prices peaked over different periods of time, and that it supports so many stores that using a tool that locks you into one doesn’t make sense. You can read more in its nomination thread here.


Invisible Hand

Five Best Price Tracking Tools

InvisibleHand isn’t quite the same as some of the other tools here—it doesn’t track prices for you, or show you a price history so you know when the best time to buy an item is—but it does tell you if an item you’re shopping for is cheaper elsewhere on the web, how much cheaper it is, and helps you find discounts on things you want to buy right now. The add-on is available for Chrome, Firefox, and Safari, and it refreshes its product prices in real-time, instead of relying on a database of price listings that may be out of date. Best of all, it works with tons of online retailers, including Amazon, NewEgg, Best Buy, Lowe’s, and airlines like Southwest, JetBlue, and Virgin Atlantic (among others.) Invisible Hand also works with Google searches, so if you just search for a product name, it’ll show you where you can find the best deals for that item—including retailers you won’t find listed in Google’s own shopping results.

Invisible Hand has been around for a long time, and it added airfare a few years ago—it may not be one of those tools that helps you play the long game, but it’s definitely one of those apps to consult before you buy anyway. For best results, you can even use it in conjunction with some of the other apps listed here to create a combo team of "lowest price today versus lowest price ever," which can really save you some money.


CheapShark

Five Best Price Tracking Tools

While most of the others in the roundup focus on products like electronics, apparel, household goods, appliances, and products of that nature, CheapShark snuck into the nominations as a great option for gamers looking to save money on video games. We’ve highlighted CheapShark in the past, especially for its unofficial Chrome extension that integrates so well with Steam’s website to make sure you don’t overpay for games. CheapShark combines all of the great places to get discounts on games (that aren’t necessarily Steam, because we all know about Steam Sales) in one place, one easily searchable directory and database of current prices, from sites including Steam, GoG, Green Man Gaming, the Humble Bundle, GameStop, Amazon, Origin, and more. Of course, it’s limited to video games, but you can search a game name not just to see how much it’ll cost you to buy, but even if you can buy it at all—and which retailer has it available. If you want, you can even filter by games currently on sale at their selected stores. When you search for a specific game, CheapShark does tell you what the cheapest-ever price was, when it hit that price, and gives you the choice to either go ahead and buy it from your choice of retailer, or to sign up for a price notification if it drops again.

Those of you who nominated it praised CheapShark for saving you tons of money on video games, even during those all-too-popular store sales that make look like they have the best prices, but in reality someone else may have a better deal just waiting for you to pick up. It doesn’t track history beyond that one all-time-low that you see when you search for a game, though. One of you even mentioned combining CheapShark’s low-price notifications with Pushover and IFTTT to make sure you get up-to-the-minute notifications when a game is discounted, meaning you never miss an all-time low or a freak flash sale or short-time discount. Now that’s dedication. Read more in its nomination thread here.


Now that you’ve seen the top five, it’s time to put them to a vote to determine the community favorite:


Honorable Mentions

This week’s honorable mention goes out to PriceJump, an Amazon comparison site that lets you search for the best price not just at Amazon, but at a ton of sites at once—somewhat similar to Invisible Hand. The site gives you simple visual cues to know whether Amazon has the best price, whether other stores are close, or whether you absolutely shouldn’t buy from Amazon, because there are more than a few competitive retailers with better price options. In addition to Amazon, the site supports hundreds of other online retailers. There’s even a Chrome extension to help you check before you buy. Read more in its nomination thread here.

Have something to say about one of the contenders? Want to make the case for your personal favorite, even if it wasn’t included in the list? Remember, the top five are based on your most popular nominations from the call for contenders thread from earlier in the week. Don’t just complain about the top five, let us know what your preferred alternative is—and make your case for it—in the discussions below.

The Hive Five is based on reader nominations. As with most Hive Five posts, if your favorite was left out, it didn’t get the nominations required in the call for contenders post to make the top five. We understand it’s a bit of a popularity contest. Have a suggestion for the Hive Five? Send us an email at tips+hivefive@lifehacker.com!

Title image by Gordon Joly.


via Lifehacker
Five Best Price Tracking Tools

New Alzheimer’s Treatment Fully Restores Memory Function For Mice

New submitter wrp103 writes Australian researchers have come up with a non-invasive ultrasound technology [abstract] that clears the brain of neurotoxic amyloid plaques — structures that are responsible for memory loss and a decline in cognitive function in Alzheimer’s patients. A slice: Publishing in Science Translational Medicine, the team describes the technique as using a particular type of ultrasound called a focused therapeutic ultrasound, which non-invasively beams sound waves into the brain tissue. By oscillating super-fast, these sound waves are able to gently open up the blood-brain barrier, which is a layer that protects the brain against bacteria, and stimulate the brain’s microglial cells to move in. Microglila cells are basically waste-removal cells, so once they get past the blood-brain barrier, they’re able to clear out the toxic beta-amyloid clumps before the blood-brain barrier is restored within a few hours. The team reports fully restoring the memories of 75 percent of the mice they tested it on, with zero damage to the surrounding brain tissue. They found that the treated mice displayed improved performance in three memory tasks – a maze, a test to get them to recognise new objects, and one to get them to remember the places they should avoid.

Share on Google+

Read more of this story at Slashdot.





via Slashdot
New Alzheimer’s Treatment Fully Restores Memory Function For Mice