
 |
|
I've come up with some interesting workarounds for missing features using @session variables and I'd like to share one with you today: DELETE ... JOIN ... LIMIT N;
okay, so we've got two tables, one with many duplicates and one with no duplicates. We want to join the tables using 'id', but only want to delete N duplicates from t1. MySQL's DELETE does not include LIMIT support when JOIN is used, so we need to work around that using some fancy footwork:
mysql> select * from t1; +------+------+ | id | abc | +------+------+ | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | +------+------+ 8 rows in set (0.00 sec)
mysql> select * from t2; +----+------+ | id | xyz | +----+------+ | 1 | 1 | +----+------+ 1 row in set (0.00 sec)
mysql> set @limit=2; set @rowCount=0; Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec)
mysql> DELETE t1.* -> FROM t1 -> JOIN t2 on (t1.id = t2.id) -> WHERE t2.id = 1 -> AND CONCAT(t1.id, t1.abc, @rowCount +1) -> = CONCAT(t1.id, t1.abc, -> CASE @rowCount -> WHEN @LIMIT THEN @rowCount:=NULL -> ELSE @rowCount := @rowCount+1 -> END -> ); Query OK, 2 rows affected (0.00 sec)
mysql> select * from t1; +------+------+ | id | abc | +------+------+ | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | | 1 | 1 | +------+------+ 6 rows in set (0.00 sec)
how it works: When MySQL first evaluates the expression, @rowCount is zero. The CONCAT in the where clause concatenates all the values given together, so at first we get CONCAT(1, 1, 1) = CONCAT(1, 1, 1). The next time through, we get CONCAT(1, 1, 2) = CONCAT(1, 1, 2). At the third execution we get CONCAT(1, 1, 3) = CONCAT(1, 1, NULL), which does not evaluate true. At this time @rowCount is now NULL, so subsequent scanned rows evaluate to CONCAT(1, 1, NULL) = CONCAT(1, 1, NULL), which can never evaluate true (NULL != NULL).
So, what interesting ways have you used @session variables to come up with solutions to intractable problems?
Post A Comment | Add to Memories | Tell a Friend | Link
 |
tcpip |
| 2008-05-14 13:09 |
| Horror (Fictional and Real), Nasty Conservatives, Gaming Updates |
| Public |
|
Recently had the opportunity at Splodge with caseopaya, severina_242, _zombiemonkey, and cvisors to see the classic Hammer film Horror of Dracula (with Peter Cushing and Christopher Lee). A good bit of cheesy horror (the working class Londoner accent complete with Gordon's gin at a Kluj inn would horrify Transylvanians). Later in the week watched the classic Vincent Price flick House on Haunted Hill which was quite clever and finally, wonder of wonders, found the memory card for the Playstation 2 which had been missing for several months and contained four hours of a saved game for Project Zero, certainly one of the best horror games that has ever been produced.
In real world horrors, there has been both the earthquake in Chengdu and a rising death toll (approximately 10,000 mostly in Mianyang) and the effects of Cyclone Nargis in Burma, where the number of dead or missing is over 100,000. The military junta that rules Burma deserves a special award for disgusting behaviour for not only blocking aid workers, but for also holding a particularly rigged constitutional referendum days after the event. An interesting comparison can be drawn between how the contemporary Chinese government is reacting to the disaster compared to their government during the Tangshan earthquake which killed approximately a quarter of a million. Communications technology is a bedrock of an open society.
On topic, there was the kerfuffle over a local Liberal Party 'blog, managed and operated by insiders, criticising leader Ted Baillieu. Although now closed it has been mirrored with history all the way to December. Not only is it amazing to think that it took that long to go through the IP logs, but in the fall-out the conservative's hatred of Jews is once again exposed. An isolated incident? Perhaps not - consider just prior Republican Congress hopefull Tony Zirkle (who, not surprisingly campaigns primarily against pornography and prostitution) decided to attend an Adolph Hitler birthday celebration sponsored by the American Nazi Party. If one was to give a broad summary it would seem that "the left" has a problem with Israel, whereas the "the right" has a problem with Jews.
Apropos there recently has been "some discussion" over an online Harry Potter RPG which called itself "Kristallnacht", which has since changed its name. Personally, I thought it was a great name for the story with enormous potential for thematic references and an oppurtunity to teach people some history via analogy (which is one of fantasy's better uses). In my own gaming worlds, I am pleased to see that a DragonQuest PBeM I am involved in has just restarted, had a good session of Bushido last Sunday and most recently I've started a Powers & Perils PBeM which has developed very quickly. Finally, one of the players in my HeroQuest PBeM has culled the archives into a story representation; it currently runs at 185 pages.
18 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
 |
krow |
| 2008-05-13 14:42 |
| Fedora, MySQL DBD, Finally |
| Public |
|
From the release notes: http://docs.fedoraproject.org/release-notes/f9/en_US/sn-DatabaseServers.html#sn-MySQL-DBD
The MySQL DBD driver has been dual-licensed and the related licensing issues have been resolved (https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=222237). The resulting apr-util-mysql package is now included in the Fedora software repositories.
I had wondered if they would ever get that in.
Post A Comment | Add to Memories | Tell a Friend | Link
I need to generate large (1TB-3TB) synthetic MySQL datasets for testing, with a number of requirements:
a) custom output formatting (SQL, CSV, fixed-len row, etc) b) referential integrity support (ie, child tables should reference PK values, no orphans,etc) c) able to generate multiple tables in parallel d) preferably able to operate without a GUI and/or manual intervention e) uses a well defined templating construct for data generation f) preferably open source
Does anyone out there know of a product that meets at least most of these requirements?
*edit* I found a PHP based data generation script (www.generatedata.com) that is extensible in its output formatting, so it should do everything I need it to do.
1 Comment | Post A Comment | Add to Memories | Tell a Friend | Link
 |
awfief |
| 2008-05-10 15:55 |
| Damned if you do, damned if you don't..... |
| Public |
|
After 2 elections where we got pissed that the Democratic candidate conceded to Bush way too early, and didn't challenge the results when we so righteously wanted him to....
Why are we all pissed that Hillary's staying on? Oh sure, I think she's lost it (pun/double meaning intended) but I have to say that she's got a tough backbone, and that's admirable and novel.
15 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
 |
awfief |
| 2008-05-10 15:42 |
| Mostly for my brothers.... |
| Public |
|
Driving home from Providence at 1:30 in the morning, I came upon a radio station playing FunkyTown.
It took all I had not to call my father at that precise moment and blast the radio exceptionally loud.
Even more bizarrely, when the song finished I channel-surfed among my 6 preset stations, and the very next song I came across was Michael Jackson's "Bad".
My restraint is extraordinary.
Post A Comment | Add to Memories | Tell a Friend | Link
 |
|
Kickfire has announced (as of April 14th, 2008) record breaking results in the TPC-H(tm) Price/Performance category at 300GB and also in overall performance in the non-clustered category at 300GB. You can find the official results here on the TPC(tm) (Transaction Processing Performance Council) website: http://www.tpc.org/tpch/results/tpch_price_perf_results.asp http://www.tpc.org/tpch/results/tpch_price_perf_results.asp?resulttype=noncluster
While the amazingly low price of the Kickfire Database Appliance 2400 will grab you (only about twice the price of a typical 4U MySQL database server) -- the amazing performance per watt is truly incredible. The 3RU Kickfire appliance used in the 300GB volume test consumes just 3RU of rack space and a measly 650watts of power.
To give an appropriate comparison, my home gaming PC contains an 800W power supply. Compared to other high performance database systems (comparison by wattage, not necessarily performance) that use tens (even hundreds) of thousands of watts, the Kickfire appliance is orders of magnitude more environmentally friendly.
Not only does it reduce the amount of physical space required, but it also reduces the costs of environmental control (cooling). It uses less manufacturing resources, is more portable between data centers and it requires less excess inventory (like spare hard disks) to maintain, all of which result in significant cost of maintenance savings.
This 'green' aspect is one of the major factors in my decision to join Kickfire, and I'm proud to be working for a company making such huge strides toward sustainable computing practices.
Full disclosure: I am a paid employee of Kickfire, Inc. The opinions expressed in my personal blog posts are my own and may not reflect those of the company. All facts and figures may be validated via the TPC website, and this blog does not represent an official posting of TPC-H data, or any other TPC related information.
Kickfire is a trademark of Kickfire, Inc. TPCH, QphH and $/QphH are trademarks of the TPC. For additional information on the TPCH benchmark, please visit the Transaction Processing Performance Council's Web site at http://www.tpc.org/.
2 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
 |
krow |
| 2008-05-09 11:17 |
| Proxy, Proxy, on the Wall, who is the fairest of them all... |
| Public |
|
Dear Lazyweb,
I am tracking three four five lots of different proxies for MySQL today:
http://forge.mysql.com/wiki/MySQL_Proxy http://consoleninja.net/code/dpm/README.html http://spockproxy.sourceforge.net/ http://sqlrelay.sourceforge.net/ http://myosotis.continuent.org/HomePage Proximo
Would someone please do a write up on which is best, which is moving forward, and synopsis the differences? I don't expect a front runner just yet, but it would be nice to see a comparison about how their development is going.
Thanks! -Brian
BTW I am sorry if I missed a proxy, if you have another one email me or leave a comment. BBTW I don't consider HScale a proxy, but yes it is damn neat. BBBTW I think the creation of proxies, points to a trend ;)
18 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
 |
krow |
| 2008-05-09 08:44 |
| Social Graphs, Portable Neighborhoods |
| Public |
|
Here is the thing.
Not everyone whom I marked as a friend in social graph games version 1, do I still hang out with. Some moved, others I have nothing in common with any longer. Hobbies change, etc.
Just as I consider Linkedin and Facebook to be two wildly different networks, I pretty much find sites in general to be this way. Sure, some friends are portable... but in many ways social sites are sort of an archive for "this is who I was hanging out with then".
Friendster is sort of 1.0 (ok, ISCA would be 0.1, and Livejournal something like a 0.5). Tribe 2.0 Facebook 3.0 (though Facebook is filled with friends 2.0 (aka high school))
Twitter, well I don't know what Twitter is.
But do I really want these to be portable? Not really.
Do I want to keep up to date with my friend's contact information?
Sure, that sounds excellent.
But the rest?
Not so much.
If Apple did a better job with Addressbook I would keep more information there (and keep it updated via some system (plaxo++)).
So what does all of this mean?
I am really bored with social sites, social graphs, and how many degrees I am away from anyone.
4 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
 |
krow |
| 2008-05-08 18:37 |
| BBC Headlines, Who would have thought... |
| Public |
|
I kid you not:
Great tits cope well with warming
5 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
Brian Moon suggest that community provided example my.cnf files would be a great thing to have on MySQLforge in this recent post: http://doughboy.wordpress.com/2008/05/06/example-mycnf-files/
I pulled out the "innodb heavy" config sample file and modified it with the standard settings that I typically start with when setting up a new InnoDB master. I've also modified the comments in the file a bit and have added some of my own too. I removed the sample slave configuration parameters (master-host, etc) because you should be using 'CHANGE MASTER TO'.
He suggested tagging such files with a 'mycnf' tag and very kindly tagged mine after I posted it :)
Feel free to share yours too and please feel free to make any comments about my configuration choices.
You can find it here (along with any other mycnf tagged files): http://forge.mysql.com/tools/search.php?t=tag&k=mycnf
Post A Comment | Add to Memories | Tell a Friend | Link
Today is my first official day with Kickfire. I've spent most of the day reading up about how the appliance works and trying to wrap my head around some of the finer details.
My starting role here is essentially as an internal consultant, which means that I'll be the one that gets the MySQL server related questions from the development team. This is going to allow me a chance to really sink my teeth further into the source code and help implement some really cool tech, which has me quite excited.
Later I will be doing some external consulting (sales, implementation, etc) that will allow me to travel a bit.
Overall, I think this position is a great fit for me and I'm really psyched.
1 Comment | Post A Comment | Add to Memories | Tell a Friend | Link
Ever since I did my original post on Crippleware I have been getting a lot of feedback from individuals about how the intersection of open source works with closed source extensions.
Open Source that is not crippleware but allows for third party extensions allows for the following:
Open and documented APIs with stable interfaces. The ability to compile or load the software without "secret sauces". The consumer right to always have access to the data they have entered.
The first two really deal with the issue of whether or not the vendor has created a "level playing field". Third party vendors who write modules expect an even handedness when dealing with APIs.
This means that there are no special tools required that cannot be obtained by a third party. No special, aka undocumented, interfaces that modify the API or service interfaces that the modules need to make use of.
No third party vendor has a right to create a closed source module, the GPL by its nature creates a cost that the third party must open source.
Quid Pro Quo works in favor of open source. If you write an extension to an open source project you play by the rules of the project's license. This means a closed source module should expect, or at least assume, to have to pay for the right to link. With exceptions to this being granted by the project. Open source adherence modules should expect that they are free to distribute their work, but realize the vendor of the original project may also distribute the module as well.
In the world of the BSD license anyone is free to extend and distribute. There is nothing inherent in the concept of open source that does not allow for proprietary extensions, it is the nature of the open source license chosen for the project which defines what is acceptable for the licensing of third party modules. Behavior which creates open source software which is crippleware comes from the author and their intent.
What do both closed source and open source modules share in common? A right to an Open API that has some level of definition and stability.
If the vendor changes the interface without notice with deliberate intent toward third party modules this is a behavior of crippleware.
Any project should be communicating API changes, this is a part of being a good steward of an organic open source model.
As an example of deliberate intent would be if a vendor created a substandard behavior via the open service API and chooses to hold back a more competitive interface for themselves. This is a behavior of crippleware.
Interfaces must be open and accessible in order to avoid being crippleware.
A consumer should expect to always be able to extract their data from an open source project in a common manner. Whether this is by printing or exporting, data portability is at the essence of the freedom open source is to provide.
Telling the user to "write it themselves" is unacceptable behavior. Users have a right to data portability, and I personally think this goes beyond the question of open source.
In an open source world you will not win a ribbon from anyone in the community for merely having an open source license. If you cripple the very nature of open, you should not be surprised when the community is not impressed.
At the end of the day it is about having appropriate table manners.
7 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
 |
krow |
| 2008-05-05 11:56 |
| Open Source, Table Manners |
| Public |
|
One of the questions I receive a lot is "how does my company work with an open source project?".
Working with open source projects is all about having table manners. There is an expected behavior for individuals and companies to have.
Use Mailing lists for questions after you have read the FAQ. Work through mailing lists to get your work in the project by discussing what you are doing openly. Respect the project maintainers time.
Most open source projects create mailing lists and FAQs. The mailing list exists for you to ask questions that are not answered in the FAQ for the project. Mailing lists often have archives, these should be searched before asking questions. Be polite when asking questions, and offer to document the solution to your question.
Take an open approach to getting your code or designs accepted by the project. I often hear "we spoke to one of the maintainers" or "we wrote twenty thousand lines of code and then they refused to take it when we offered to donate it". Before writing any code, discuss your intentions with the widest distribution model possible. Keep people from being surprised. Tailor your code around how code already works in the project. If there are no clear guidelines offer to write them down based on what the project is doing. A little leg work on your part shows that you wish to be a good citizen.
Doing work outside of your own needs, shows you wish to be a good contributor to the project. For example, this can be done by reviewing other people's code or by writing documentation.
Finally, do not expect anyone to do anything for free. Most groups wish to improve on their projects, but having "enough time" is always an issue. Be open to offering money, time, or resources in order to get your problem solved. Realize that for what you offer there may be a down side as well for the project.
Free hardware still has to be installed and properly setup. Money may be an issue because of foreign currency exchanges or because it complicates the individuals taxes. Offering people can be good, but realize that then the project will have to take the burden of training and answering questions.
Having good table manners is the key to working with open source projects.
Post A Comment | Add to Memories | Tell a Friend | Link
 |
krow |
| 2008-05-04 21:50 |
| Seattle Cardboard Fight Club! |
| Public |
|
Post A Comment | Add to Memories | Tell a Friend | Link
 |
tcpip |
| 2008-05-05 13:39 |
| Liberal Religion and Neo-Astrology, Champagne Breakfasts, Clusters and CMSs |
| Public |
|
Gave an address at the Melbourne Unitarian Church on Sunday on Reverend Stephen Fritchman, a radical liberal in the U.S. who caused a great deal of trouble for the political establishment during the 1940s, 50s and 60s. On a vaguely related topic I found myself debating on convert_me last week with astrologers, of all people. Intrigued to discover that some of that ilk now claim (or rather, admit as the statistics and science is beyond reasonable doubt) that it has no predictive value whatsoever, but rather can only be used as a metaphorical and instrospective approach. So, after all those centuries it is finally acknowledged to be fiction.
Last Saturday the deco-apartment of Das Hoehnhauss/Casa di Lafayette held a champagne breakfast with various teas, Timorese coffee, lots of pancakes, almond shortbread, silverware and fine china. In attendence were caseopaya's new workmate and partner along with imajica_lj. We're hoping to turn this into a semi-regular event as it's a delightful way to waste away a Saturday morning and most of an afternoon and catch up with a small group of people as well. We're gradually building a list of people to come along, but if anyone is particularly keen to attend in the next couple, please drop a line below.
Work-related matters have been quite busy of late and we've been somewhat short-staffed. Upgrading the dual-core Opteron systems to quad-cores on Tango is a necessity if we wish to reach at least somewhere close to the c7 Teraflop peak but (as one would expect) it hasn't entirely been smooth sailing. On a completely different tangent, I've been investigating the relative competitive benefits of Drupal vs Plone CMSs for ARCS. Having some experience with both does lead me towards the former for the sake of simplicity, but I'm interested to hear contrary views.
40 Comments | Post A Comment | Add to Memories | Tell a Friend | Link
|
 |
|
 |
 |