Showing entries 81 to 90 of 104
« 10 Newer Entries | 10 Older Entries »
Displaying posts with tag: Geek (reset)
Useless use of if award

Similar to the useless use of cat award. The useless use of if award highlights code examples where people use the if function or ternary operator when the return of the expression does the exact same thing. I first noticed this with returning boolean values from php functions. To protect the innocent the winner of today’s award will remain anonymous.

<anonymous> to my knowledge, youll have to SUM(IF(your_field <> “”, 1, 0)) as total_non_empty

Ignoring that the whole query should be using where your_field != ” and group by the non if() way to write this is:

SUM(your_field <> ”)

These examples aren’t an award to a specific person since I’m digging them up from my memory. This pretty much applies to both C and PHP.

< ?php

function foo()

{

$str = 'foo';

return $str == 'foo' ? TRUE : FALSE;
}

?>

Can be …

[Read more]
Why uptime is bad

Growing up in the world of linux uptime was always considered a good thing. On IRC every once in a while someone would post an uptime. Everyone else in that channel would then check their uptime and if it was greater or close they would post it in the channel. Most of these systems were home linux boxes used for compiling random programs or maybe hosting a webserver for experimenting. It was fun to see how long we could keep them running for. Since those days I have come to realize that high uptimes are a bad thing.
Keeping a server up for months or even years means that you aren’t maintaining it. It hasn’t been kept up to date with new kernels that have fixes for security holes. It doesn’t have new packages or new tools that can help it run more efficiently and have features that can make using it easier. It’s also not up to date with new servers that are being deployed which means that people logging into your server with a high …

[Read more]
The wrong way to upgrade MySQL

Expect a longer post in the near future on upgrade procedures. For now enjoy this quote from a gentoo user illustrating the worst way to upgrade.

linolium: is there a way to wipe every single table and start over from scratch?
linolium: ( the upgrade from mysql 4 to 5 didn’t go as smoothly as planned
me: did you read the upgrade notes?
linolium: no, I just hoped that portage would be kind enough to do those things for me

MySQL User Conference 2006

Every year the user conference gets better and better. I’m not sure if it’s the actual conference or just that I know so many more people than I did the year before so I’m that much more excited to see them all again. I was a speaker this year which is something like being a C celebrity. The attendees at the conference were split into a few very distinct groups. High order geeks, geeks with questions, and business people. The sessions seemed to be setup to appeal to one of these three groups. Of the sessions I attended my favorites were the row based replication session (which inspired Row based replication and application developers) and Timour Katchaounov’s session on new features of the 5.0 optimizer.

It was interesting walking around the conference meeting different people from various backgrounds and …

[Read more]
Row based replication and application developers

While attending Lars Thalmann’s session on Row Based Replication I began to think about how the new features will allow us to do creative new things with MySQL Replication. For example we can now issue an update query with a join and have one slave update only rows from table a and another slave only update rows from table b. This is very powerful but also very dangerous.

My experience has been that the average php developer can write average sql but doesn’t tend to think about the overall impact on a system when writing code. This is where system architects apply. A system architect can view an entire system and design it’s components to scale well, be fault tolerant and easily maintained. An application level developer will implement the system based on the design. Replication is a very deceptive convergence between the architect role and the developer …

[Read more]
MySQL Snapshot from a full disk. Tar over ssh

Have you ever tried to take a snapshot from a mysql server only to find an hour later that the box ran out of disk space when trying to create the tar ball? An easy solution is to use ssh to pipe the tar data directly to another server without it even touching the disk. For those unfamiliar with unix shells or pipes a pipe allows you to tie the output of one program to the input of another. This is most commonly used to manipulate that stream of data. For example if you want to find a specific file in a directory. In these examples cartman is server A (where the commands are ran from). Stan is server B.

cartman> ls | grep mysql-5
mysql-5.0

The | (pipe) tells the shell to direct the output of ls to the input of grep which looks for the pattern ‘mysql-5′. This same functionality can be used with the tar command. This next command would compress a file and uncompress it on itself. Of course this is pointless. Until we …

[Read more]
3 Minute MySQL (tuning)

While reading planetmysql.org I ran across this Tune a MySQL server in 5 minutes.. I think that entry is really missing a lot in terms of actual tuning for the real world. Also I thought max_user_connections is number of connections per hour. Since I only have 3 minutes I can’t look it up! You probably don’t want to set this with apache.

So here in three minutes are the four variables you really need and some generic guidlines for setting them. This assumes that MySQL is running on it’s own server and has one apache server connecting to it.

max_connections - set to the same (or a little bigger than) as MaxChildren from apache if you’re only using one mysql connection per request (this is most common) key_buffer_size - Set to roughly half your available ram. Remember this is a quick and dirty tuning. We only have 3 minutes! …[Read more]
The manual search

I have had a blog entry waiting to be posted for a while about how bad the manual search has sucked since the versioning was implemented. I love the versioning but not being able to search it has been maddening. That post will never see light. The manual search has been fixed! We now have the best of both worlds. A versioned manual and search that works.
(type this into your browser address bar)

mysql.com/search term

For those of you that might not know this also works on php.net and freshmeat.net.

Does MySQL really care?

Other people have already drilled into the Oracle purchase of Sleepycat enough so I only have one question. Does any MySQL user really care that Oracle bought Sleepycat? Was anyone using BDB in production? Why?

I/O Scheduling

An elevator picks people up and moves them to different floors based on where they have requested. If an elevator picked up exactly one person on the ground floor of a building, dropped them off, and went down to get another person it wouldn’t be very efficient. Modern elevators pick up people and move them between floors in an optimal pattern. Disk access is pretty much the same idea if you think of the disk head as an elevator and the disk as a building. It takes time to move an elevator just as it takes time to move a disk head. Modern operating systems can change the order of disk accesses into a more optimal pattern.

There are many different algorithms for scheduling I/O. I’m going to cover the ones I know from linux and how they can help you make the best use of your servers disks.


CFQ (Completely Fair Queue)

CFQ maintains an i/o queue per process. Processes can post multiple reads …

[Read more]
Showing entries 81 to 90 of 104
« 10 Newer Entries | 10 Older Entries »