REPLACE INTO will actually perform a delete and then an insert, while INSERT … ON DUPLCIATE KEY UPDATE will perform an update (as the name suggests). I would think the latter would be faster. I have not done any performance testing between the two, but it only seems logical the update would be faster than the delete/insert. Please correct me if I’m wrong. Since the two statements both end up with the same result, I’m not sure yet what the benefit of REPLACE into it.
Although it’s not officially announced, our read/write api is now out and in beta. It’s not officially launched on the site or anything, but we are looking for interested partners. Docs are here
I found a very good explanation of how to set up public key authentication over ssh. I’m always looking for it when I need it, and it always takes forever. http://www.petefreitag.com/item/532.cfm You can also use ssh-copy-id, I’m not sure what the specifics are behind it, but it seems to be available occasionally (Fedora 6) and not in other places (OS X 10.4.8).
For a long time, whenever I wanted to do paging to browse through a table, I used to run 2 queries. The first would get the results, and the second would be an almost identical query, with a count() instead of fields, and I’d use the result of the second query to figure out how many pages I would need. Now there’s a better solution, and it’s called found_rows(). Say you have a simple select statement:
Regular expressions are awesome. However, sometimes doing everything in them is extremely difficult, or impossible. Luckily, we can flex the power of preg_replace’s ’e’ option to execute the replacement string as PHP code. The reason why I found this is was I was looking for a suitable URL auto-linker that could shorten the url to a certain length. I found several examples on PHP.net, but unfortunately none of them did a good job of shortening the URL, or formatting it in a special way.
I saw a post on digg.com about how it’s nice to have “pretty urls” that are easy to tell people. While i’m not sure anyone would remember rustyrazorblade.com slash some ridiculous post name, it’s nice to have for search engines. Unfortunately, it didn’t really go into detail about how to accomplish the urls. A lot of people suggested mod_rewrite. Yes, it’s something you can use, but kind of a pain to set up.
I do not think you can use the result of a stored procedure in an ad-hoc subquery. On my social network, LetsGetNuts.com, I have a Friend table. This is the structure: mysql> describe Friend; +—————-+—————+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +—————-+—————+——+—–+———+——-+ | fkUser | int(11) | YES | MUL | NULL | | | fkFriend | int(11) | YES | MUL | NULL | | | confirmed | enum(‘Y’,‘N’) | YES | MUL | NULL | | | confirmed_date | date | YES | | NULL | | +—————-+—————+——+—–+———+——-+ 4 rows in set (0.
Glad I was able to think of something interesting enough for the digg community to vote up so highly, but I was a little surprised to see that question submission has completely stopped. I’ve been sitting at 388 all weekend. It was interesting to see traffic spike up to 67K pageviews for the day - it was mostly contained in a period of 5 hours. Also funny to see people try to mess with the server, one person wrote a script to submit the same question in a loop.
I’ve created an experiment, askhaddad.com. I answer all questions in the order they are received, unless they are blatent spam or nonsense. Askhaddad.com is an anti-social q&a; site - there is no user community, and I am the only one that answers questions.
Maybe not breaking news, but I think it’s interesting enough of a point, and I didn’t really find anything about the topic when I googled it. If you do any addition, subtraction, multiplication, or division (and probably a lot more mathematical functions for that matter) and NULL is one of your values, the entire expression will evaluate to NULL. For example, this statement returns NULL: mysql> select 4 + NULL; +———-+ | 4 + NULL | +———-+ | NULL | +———-+ Normally you wouldn’t do the above in such a simple way, for instance, you might do some addition in a subquery.