User Group Video Up, and Video Camera Review

Download the video at:

http://technocation.org/videos/original/BostonMySQLJanUserGroupBrianAkerLg.wmv
– 520 kbps, 320 x 240, 354M. Small size, low quality, but you can still see the slides and hear everything.

http://technocation.org/videos/original/BostonMySQLJanUserGroupBrianAkerSm.wmv – 45 kbps, 320 x 120, 29M. Small size, low quality, but you can still see the slides and hear everything.

Technocation, Inc. received a donation of a Sony Handycam DCR SR80 (http://tinyurl.com/yvyfam ), extra-long battery, microphone (proprietary Sony that goes with the camera).

In a short sentence: I am impressed. The sound quality (on the large version) is almost exactly what I heard. Granted, I have some hearing loss, but I forgot to bring the microphone, and you can still hear audience questions very well. The video quality is great, too. The hard disk is perfect, because files can be copied over or burned directly to DVD. It records in MPEG-4 format.

The 1 hour 38 minute talk took up less than 6 gigs of space raw (I forget how much exactly, but it cuts the files into 2G chunks, and there were 3). This gives at least 10 hours of recording time before needing to dump to disk. This is a very exciting prospect for the MySQL Conference and Expo at the end of April, I’ll be able to video a LOT.

Special thanks go to the User Group member (who may wish to remain anonymous, but I forgot his name anyway, so if he wishes to comment he can, or just e-mail me so I remember your name!) who talked to me about codecs and which programs to use, because they worked!

I was not quite ready for the start of the User Group, and had to run out to my car to get the tripod, so the first minute or so (until 1:25) is me setting up the tripod — I apologize for the movement.

You can see the “Night Shot” functionality early on, when I focus on Brian and turn it on. It does a great job, but loses a lot of color (1:53 until 1:59).

I was disappointed that when you connect the DC power supply, the video stops (so there’s a few hops int here).

Brian takes some slides, starts talking, and questions ensue. The basic slides were about MySQL’s internal architecture.

Some links:
MySQL and dual-master/circular replication
There’s a great article by Guiseppe Maxia at: http://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html

And a free chapter on Replication from Jeremy Zawodny’s
http://www.oreilly.com/catalog/hpmysql/chapter/ch07.pdf

Around 27:00 there is a reference to Jim Gray’s “Black Book”, which is entitled “Transaction Processing: Concepts and Techniques” and can be found here: http://tinyurl.com/2md3tb

http://forge.mysql.com/wiki/Top10SQLPerformanceTips

Download the video at:

http://technocation.org/videos/original/BostonMySQLJanUserGroupBrianAkerLg.wmv
– 520 kbps, 320 x 240, 354M. Small size, low quality, but you can still see the slides and hear everything.

http://technocation.org/videos/original/BostonMySQLJanUserGroupBrianAkerSm.wmv – 45 kbps, 320 x 120, 29M. Small size, low quality, but you can still see the slides and hear everything.

Technocation, Inc. received a donation of a Sony Handycam DCR SR80 (http://tinyurl.com/yvyfam ), extra-long battery, microphone (proprietary Sony that goes with the camera).

In a short sentence: I am impressed. The sound quality (on the large version) is almost exactly what I heard. Granted, I have some hearing loss, but I forgot to bring the microphone, and you can still hear audience questions very well. The video quality is great, too. The hard disk is perfect, because files can be copied over or burned directly to DVD. It records in MPEG-4 format.

The 1 hour 38 minute talk took up less than 6 gigs of space raw (I forget how much exactly, but it cuts the files into 2G chunks, and there were 3). This gives at least 10 hours of recording time before needing to dump to disk. This is a very exciting prospect for the MySQL Conference and Expo at the end of April, I’ll be able to video a LOT.

Special thanks go to the User Group member (who may wish to remain anonymous, but I forgot his name anyway, so if he wishes to comment he can, or just e-mail me so I remember your name!) who talked to me about codecs and which programs to use, because they worked!

I was not quite ready for the start of the User Group, and had to run out to my car to get the tripod, so the first minute or so (until 1:25) is me setting up the tripod — I apologize for the movement.

You can see the “Night Shot” functionality early on, when I focus on Brian and turn it on. It does a great job, but loses a lot of color (1:53 until 1:59).

I was disappointed that when you connect the DC power supply, the video stops (so there’s a few hops int here).

Brian takes some slides, starts talking, and questions ensue. The basic slides were about MySQL’s internal architecture.

Some links:
MySQL and dual-master/circular replication
There’s a great article by Guiseppe Maxia at: http://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html

And a free chapter on Replication from Jeremy Zawodny’s
http://www.oreilly.com/catalog/hpmysql/chapter/ch07.pdf

Around 27:00 there is a reference to Jim Gray’s “Black Book”, which is entitled “Transaction Processing: Concepts and Techniques” and can be found here: http://tinyurl.com/2md3tb

http://forge.mysql.com/wiki/Top10SQLPerformanceTips

Oracle Releases Free SQL Developer That Can View MySQL

From: http://tinyurl.com/299h29

Oracle Updates Free SQL Developer Tools
Oracle Corp. has released the first major upgrade to SQL Developer, its free visual database development tool. The new version can browse non-Oracle databases, including Microsoft SQL Server and Access and MySQL AB’s open-source MySQL. The SQL Developer 1.1 tool simplifies the creation and debugging of code in standard SQL and in Oracle’s proprietary PL/SQL programming languages.

Roland Bouman has an excellent blog post on it:
http://rpbouman.blogspot.com/2007/01/oracle-sql-developer-11-supports-mysql.html

From: http://tinyurl.com/299h29

Oracle Updates Free SQL Developer Tools
Oracle Corp. has released the first major upgrade to SQL Developer, its free visual database development tool. The new version can browse non-Oracle databases, including Microsoft SQL Server and Access and MySQL AB’s open-source MySQL. The SQL Developer 1.1 tool simplifies the creation and debugging of code in standard SQL and in Oracle’s proprietary PL/SQL programming languages.

Roland Bouman has an excellent blog post on it:
http://rpbouman.blogspot.com/2007/01/oracle-sql-developer-11-supports-mysql.html

Caveat: DATEs and DATETIMEs

A small bug/feature, which I created a new bug for at http://bugs.mysql.com/25706. Basically, the CURRENT_DATE() function seems to assign a time to dates, and that time is 00:00:00. In fact, all DATE formats are actually DATETIMEs with the date field of 00:00:00 and hidden.

This interferes with queries that use the date as an actual date and expect the date to include everything up until 23:59:59 of that day. The easiest way to reproduce this:

SELECT IF(NOW() BETWEEN '2007-01-17' AND '2007-01-18','yes','no') AS test\G
test: no
1 row in set (0.00 sec)

In fact, the following query always returns “no”, unless it’s exactly midnight:

SELECT IF(NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE(),'yes','no') AS test\G
test: no
1 row in set (0.00 sec)

This does not make logical sense — NOW() should always be between “yesterday” and “today”. It’s one thing to be cautious not to compare DATEs and DATETIMEs to each other. However, this is a bit too much of a bug for me. And it’s not just the BETWEEN…AND syntax — that just converts to >= and < = to. For a test of this: SELECT IF(NOW() >= CURRENT_DATE() – INTERVAL 1 DAY AND NOW() < = CURRENT_DATE(),'yes','no') AS test\G test: no 1 row in set (0.00 sec)

Again, NOW() should fall between “yesterday” and “today”.

There is a workaround, although poor at best:

SELECT IF(DATE(NOW()) BETWEEN CURRENT_DATE() AND CURRENT_DATE(),'yes','no') AS test\G
test: yes
1 row in set (0.00 sec)

I found this with both MySQL 4.1.19-standard-log and 5.0.19-standard-log.

Now, (thanx to Roland) this is because when you cast a DATE to a DATETIME, it gets the 00:00:00 time put in. And when you’re comparing a DATE and a DATETIME, MySQL implicitly casts the DATE to DATETIME. It’s a wonderful gotcha, and I understand why it is, but I do not like it.

It also means that I have to go look at a whole bunch of reports…..

Oracle also works this way, and I’m guessing all db’s do, but I’d like confirmation if folks have any. What a pain.

A small bug/feature, which I created a new bug for at http://bugs.mysql.com/25706. Basically, the CURRENT_DATE() function seems to assign a time to dates, and that time is 00:00:00. In fact, all DATE formats are actually DATETIMEs with the date field of 00:00:00 and hidden.

This interferes with queries that use the date as an actual date and expect the date to include everything up until 23:59:59 of that day. The easiest way to reproduce this:

SELECT IF(NOW() BETWEEN '2007-01-17' AND '2007-01-18','yes','no') AS test\G
test: no
1 row in set (0.00 sec)

In fact, the following query always returns “no”, unless it’s exactly midnight:

SELECT IF(NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE(),'yes','no') AS test\G
test: no
1 row in set (0.00 sec)

This does not make logical sense — NOW() should always be between “yesterday” and “today”. It’s one thing to be cautious not to compare DATEs and DATETIMEs to each other. However, this is a bit too much of a bug for me. And it’s not just the BETWEEN…AND syntax — that just converts to >= and < = to. For a test of this: SELECT IF(NOW() >= CURRENT_DATE() – INTERVAL 1 DAY AND NOW() < = CURRENT_DATE(),'yes','no') AS test\G test: no 1 row in set (0.00 sec)

Again, NOW() should fall between “yesterday” and “today”.

There is a workaround, although poor at best:

SELECT IF(DATE(NOW()) BETWEEN CURRENT_DATE() AND CURRENT_DATE(),'yes','no') AS test\G
test: yes
1 row in set (0.00 sec)

I found this with both MySQL 4.1.19-standard-log and 5.0.19-standard-log.

Now, (thanx to Roland) this is because when you cast a DATE to a DATETIME, it gets the 00:00:00 time put in. And when you’re comparing a DATE and a DATETIME, MySQL implicitly casts the DATE to DATETIME. It’s a wonderful gotcha, and I understand why it is, but I do not like it.

It also means that I have to go look at a whole bunch of reports…..

Oracle also works this way, and I’m guessing all db’s do, but I’d like confirmation if folks have any. What a pain.

Private: OurSQL Episode 6: Falcon, part 2

In this episode, the second part in a two-part series about Falcon, the new storage engine provided by MySQL, we talk about what happens when commit, going over and explaining the serial log and indexes.

Direct play episode 6 at:
http://technocation.org/content/oursql-episode-6%3A-falcon%2C-part-2-0

Subscribe to the podcast by clicking:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=206806301

You can Direct download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Links:
Falcon features:
http://dev.mysql.com/doc/falcon/en/se-falcon-features.html

Falcon documentation
http://www.mysql.org/doc/refman/5.1/en/se-falcon.html

Special thanks to Arjen Lentz (http://arjen-lentz.livejournal.com/ ) and Mark Matthews (http://www.jroller.com/page/mmatthews ) of MySQL AB for their answers and explanations, and Jim Starkey and Technocation for their use of the audio from the July 2006 Boston User Group meeting with Jim Starkey.

Acknowledgements

http://www.technocation.org

http://music.podshow.com

http://www.russellwolff.com

http://www.smallfishadventures.com/Home.html “The Thank you song” — Smallfish

Feedback

If you have any feedback about this podcast, or want to suggest topics to cover in future podcasts, please email

podcast@technocation.org

You can also:

Call the comment line at +1 617-674-2369

Or use Odeo to leave a voice mail through your computer:
http://odeo.com/sendmeamessage/Sheeri

Or use the Technocation forums:
http://technocation.org/forum

In this episode, the second part in a two-part series about Falcon, the new storage engine provided by MySQL, we talk about what happens when commit, going over and explaining the serial log and indexes.

Direct play episode 6 at:
http://technocation.org/content/oursql-episode-6%3A-falcon%2C-part-2-0

Subscribe to the podcast by clicking:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=206806301

You can Direct download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Links:
Falcon features:
http://dev.mysql.com/doc/falcon/en/se-falcon-features.html

Falcon documentation
http://www.mysql.org/doc/refman/5.1/en/se-falcon.html

Special thanks to Arjen Lentz (http://arjen-lentz.livejournal.com/ ) and Mark Matthews (http://www.jroller.com/page/mmatthews ) of MySQL AB for their answers and explanations, and Jim Starkey and Technocation for their use of the audio from the July 2006 Boston User Group meeting with Jim Starkey.

Acknowledgements

http://www.technocation.org

http://music.podshow.com

http://www.russellwolff.com

http://www.smallfishadventures.com/Home.html “The Thank you song” — Smallfish

Feedback

If you have any feedback about this podcast, or want to suggest topics to cover in future podcasts, please email

podcast@technocation.org

You can also:

Call the comment line at +1 617-674-2369

Or use Odeo to leave a voice mail through your computer:
http://odeo.com/sendmeamessage/Sheeri

Or use the Technocation forums:
http://technocation.org/forum

MySQL Queues, part II — groups of queues

I believe this is a huge optimization for a heavily implemented Web 2.0 idea.

This article makes simple work of groups of queues. An example of this would be “the most recent 10 people to view an article,” so each article has a queue of up to 10 items in it. This method eliminates the need for multiple SQL statements or using TRIGGERS to check to see if the queue is full.

I bow down to Baron Schwartz, aka Xarpb, for his article on how to implement a queue in SQL:

http://www.xaprb.com/blog/2007/01/11/how-to-implement-a-queue-in-sql/

I am very excited because this also works for groups of objects, and we’re about to implement something at work that needs this idea. The idea of “the most recent x things” or “the top x things” is huge, especially in social networking, and probably one of the most often sought after features.

The biggest issue is that in order to display, say, the most recent posts, a query has to find the time of all the posts and only get the most recent 10. This can be made easy by the logic that the 10 most recent posts are the last 10 rows in the table. Any logic is also added, as in “the last 10 rows in the table viewable and for this guest/login.”

What if you want to track the last 10 people to view the post? Aha, this gets trickier. Convention would say that when a person views a post, have an SQL transaction that adds the information (person x viewed post y at time z and anyo other info, such as browser type, IP, etc) and if there are more than 10 entries for that post, delete the oldest ones until you have 10 entries. This transaction could be done via the application code or via triggers in MySQL 5.0 and up.

However, both those methods use multiple SQL queries, and in the case that an article has been viewed fewer than 10 times, the queries are unnecessary. And given each article has a different popularity — some are viewed lots more than others — running multiple queries ends up being a waste of cycles for articles whose last 10 viewers change infrequently.

These commands were tested on MySQL 4.1.19-standard-log. I use REPLACE INTO because it’s shorter than SELECT…ON DUPLICATE KEY UPDATE, and yes, those aren’t

Let’s say you have a New Year’s Resolution to eat 5 servings of fruits and 5 servings of vegetables per day. The only thing that changes from Baron’s example is that we add a group field (called ‘kind’). The “fruit” field was changed to “edible” and will still contain the name of the edible.

As Baron does, I will use a MySQL-specific command. However, he used SELECT...ON DUPLICATE KEY and I will use REPLACE, as it is smaller in syntax.

use test;
CREATE TABLE q (
id int NOT NULL,
modulo int NOT NULL,
kind char(1) NOT NULL,
food varchar(10) NOT NULL,
PRIMARY KEY(id,kind),
UNIQUE KEY(modulo,kind)
);

The basic statement is below — I’ve added AS clauses to make the variables more clear. The modulus is, in this case, 5, but in the article case above would be 10. The “kind” is either “f” or “v”, these are your groups of queues. In this case they stand for “fruits” and “vegetables” but they might be numbers referring to articles. The “food” stands for the type of food eaten, but in the article scenario would represent the username or user id of the customer viewing the article.

REPLACE INTO q (id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1) AS id,
(COALESCE(MAX(id), -1) + 1) MOD 5 AS modulo,
'f' AS kind,
'apple' AS food
FROM q WHERE kind='f';

mysql> SELECT * FROM q order by kind,id;

id modulo kind food
0 0 f apple

As expected, 1 "fruit" row.

mysql> REPLACE INTO q(id, modulo, kind, food)
-> SELECT
-> (COALESCE(MAX(id), -1) + 1),
-> (COALESCE(MAX(id), -1) + 1) MOD 5,
-> 'f',
-> 'orange'
-> FROM q WHERE kind='f';
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM q order by kind,id;

id modulo kind food
0 0 f apple
1 1 f orange

As expected, 2 "fruit" rows.


mysql> REPLACE INTO q(id, modulo, kind, food)
-> SELECT
-> (COALESCE(MAX(id), -1) + 1),
-> (COALESCE(MAX(id), -1) + 1) MOD 5,
-> 'v',
-> 'okra'
-> FROM q WHERE kind='v';
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM q order by kind,id;

id modulo kind food
0 0 f apple
1 1 f orange
0 0 v okra

As expected, 2 "fruit" rows and 1 "vegetable" row. Now, let's quickly populate the fields so the "fruit" group reaches it's maximum of 5.

REPLACE INTO q(id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1),
(COALESCE(MAX(id), -1) + 1) MOD 5,
'v',
'squash'
FROM q WHERE kind='v';

REPLACE INTO q(id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1),
(COALESCE(MAX(id), -1) + 1) MOD 5,
'f',
'peach'
FROM q WHERE kind='f';

REPLACE INTO q(id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1),
(COALESCE(MAX(id), -1) + 1) MOD 5,
'f',
'cherries'
FROM q WHERE kind='f';

REPLACE INTO q(id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1),
(COALESCE(MAX(id), -1) + 1) MOD 5,
'f',
'pear'
FROM q WHERE kind='f';

REPLACE INTO q(id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1),
(COALESCE(MAX(id), -1) + 1) MOD 5,
'v',
'celery'
FROM q WHERE kind='v';

SELECT * FROM q order by kind,id;

id modulo kind food
0 0 f apple
1 1 f orange
2 2 f peach
3 3 f cherries
4 4 f pear
0 0 v okra
1 1 v squash
2 2 v celery

We have 5 values in the “fruit” group and 3 values in the “veggie” group. Now let’s see what happens when another fruit is added:

REPLACE INTO q(id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1),
(COALESCE(MAX(id), -1) + 1) MOD 5,
'f',
'banana'
FROM q WHERE kind='f';
Query OK, 2 rows affected (0.00 sec)
Records: 1 Duplicates: 1 Warnings: 0

Note that a duplicate has been found! This is because the modulo wrapped around. The id of “banana” is 5, and 5 modulo 5 = 0 – the same as 0 modulo 5, which was the modulo value previously taken by “apple”. So “apple” is pushed off the end of the queue.

SELECT * FROM q order by kind,id;

id modulo kind food
1 1 f orange
2 2 f peach
3 3 f cherries
4 4 f pear
0 5 f banana
0 0 v okra
1 1 v squash
2 2 v celery

To find the current list of all fruits, with the most recent fruit first, run:

SELECT * FROM q WHERE kind='f' ORDER BY id DESC;

id modulo kind food
1 1 f orange
2 2 f peach
3 3 f cherries
4 4 f pear
0 5 f banana

Let’s get back to the example of page views, though. We probably care about when the pages were viewed, so let’s add a timestamp:

ALTER TABLE q ADD COLUMN fed TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

I ran the queries again, with some delays, so the timestamps wouldn’t all be the same.

SELECT * FROM q order by id,kind;

id modulo kind food fed
1 1 f orange 2007-01-15 14:48:25
2 2 f peach 2007-01-15 14:48:28
3 3 f cherries 2007-01-15 14:48:28
4 4 f pear 2007-01-15 14:48:31
5 0 f banana 2007-01-15 14:48:34
1 1 v squash 2007-01-15 14:48:28
2 2 v celery 2007-01-15 14:48:31
3 3 v beet 2007-01-15 14:48:31
4 4 v spinach 2007-01-15 14:48:34
5 0 v cucumber 2007-01-15 14:48:34

Or, what the query would be in a real system — find all fruits eaten and sort by time, most recent first:

SELECT food,fed FROM q WHERE kind=’f’ ORDER BY fed DESC;

banana 2007-01-15 14:48:34
pear 2007-01-15 14:48:31
peach 2007-01-15 14:48:28
cherries 2007-01-15 14:48:28
orange 2007-01-15 14:48:25

edit:
One edge case to be aware of — reaching the limit of the id field.

If your application does 100 of these per second, an UNSIGNED INT will last 1.36 years — not so great. You should use an UNSIGNED INT because you’re never going to have a negative number, and a signed int would only last just over 8 months if there were 100 REPLACEs per second.

(60 seconds/min, 60 min/hr, 24 hrs/day, 365 days/yr)
4294967295/60/60/24/365/100=1.3619251950

So, for scaling/known high traffic, use a BIGINT. However, in this case, do NOT use UNSIGNED, as all MySQL arithmetic is done with signed bigints or doubles. Not that it matters in this case; at 100 REPLACEs per second, you will wrap at 2.9 billion years:

9223372036854775807/60/60/24/365/100=2,924,712,086.7753601074

Let’s say your system does 10,000 of these REPLACEs per second, for eternity (our main database system, where we’re about to use this, average 6,000 qps, not all writes, but it’s a good figure to use for our own numbers) — move the decimal places a few spots over and you’re down to running out of numbers in 29 million years.

That’s an OK limit for us. 🙂

I believe this is a huge optimization for a heavily implemented Web 2.0 idea.

This article makes simple work of groups of queues. An example of this would be “the most recent 10 people to view an article,” so each article has a queue of up to 10 items in it. This method eliminates the need for multiple SQL statements or using TRIGGERS to check to see if the queue is full.

I bow down to Baron Schwartz, aka Xarpb, for his article on how to implement a queue in SQL:

http://www.xaprb.com/blog/2007/01/11/how-to-implement-a-queue-in-sql/

I am very excited because this also works for groups of objects, and we’re about to implement something at work that needs this idea. The idea of “the most recent x things” or “the top x things” is huge, especially in social networking, and probably one of the most often sought after features.

The biggest issue is that in order to display, say, the most recent posts, a query has to find the time of all the posts and only get the most recent 10. This can be made easy by the logic that the 10 most recent posts are the last 10 rows in the table. Any logic is also added, as in “the last 10 rows in the table viewable and for this guest/login.”

What if you want to track the last 10 people to view the post? Aha, this gets trickier. Convention would say that when a person views a post, have an SQL transaction that adds the information (person x viewed post y at time z and anyo other info, such as browser type, IP, etc) and if there are more than 10 entries for that post, delete the oldest ones until you have 10 entries. This transaction could be done via the application code or via triggers in MySQL 5.0 and up.

However, both those methods use multiple SQL queries, and in the case that an article has been viewed fewer than 10 times, the queries are unnecessary. And given each article has a different popularity — some are viewed lots more than others — running multiple queries ends up being a waste of cycles for articles whose last 10 viewers change infrequently.

These commands were tested on MySQL 4.1.19-standard-log. I use REPLACE INTO because it’s shorter than SELECT…ON DUPLICATE KEY UPDATE, and yes, those aren’t

Let’s say you have a New Year’s Resolution to eat 5 servings of fruits and 5 servings of vegetables per day. The only thing that changes from Baron’s example is that we add a group field (called ‘kind’). The “fruit” field was changed to “edible” and will still contain the name of the edible.

As Baron does, I will use a MySQL-specific command. However, he used SELECT...ON DUPLICATE KEY and I will use REPLACE, as it is smaller in syntax.

use test;
CREATE TABLE q (
id int NOT NULL,
modulo int NOT NULL,
kind char(1) NOT NULL,
food varchar(10) NOT NULL,
PRIMARY KEY(id,kind),
UNIQUE KEY(modulo,kind)
);

The basic statement is below — I’ve added AS clauses to make the variables more clear. The modulus is, in this case, 5, but in the article case above would be 10. The “kind” is either “f” or “v”, these are your groups of queues. In this case they stand for “fruits” and “vegetables” but they might be numbers referring to articles. The “food” stands for the type of food eaten, but in the article scenario would represent the username or user id of the customer viewing the article.

REPLACE INTO q (id, modulo, kind, food)
SELECT
(COALESCE(MAX(id), -1) + 1) AS id,
(COALESCE(MAX(id), -1) + 1) MOD 5 AS modulo,
'f' AS kind,
'apple' AS food
FROM q WHERE kind='f';

Continue reading “MySQL Queues, part II — groups of queues”

OurSQL Episode 5: Falcon, Part 1

Finally, episode 5 is here. In this episode, the first part in a two-part series about Falcon, the new storage engine provided by MySQL, we talk about what happens when you query a Falcon table, going over and explaining MVCC and the record cache. Next episode will go over the serial logs and indexes.

Direct play episode 5 at:
http://technocation.org/content/oursql-episode-5%3A-falcon%2C-part-1-0

Subscribe to the podcast by clicking:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=206806301

You can Direct download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Jim Starkey is a great speaker, and very funny to listen to – at one point he refers to a performance hit as a “performance surprise”. He’s also a piece of history – listen for his take on MVCC, which he invented.

Links:
Falcon features:
http://dev.mysql.com/doc/falcon/en/se-falcon-features.html

Falcon documentation
http://www.mysql.org/doc/refman/5.1/en/se-falcon.html

Special thanks to Arjen Lentz (http://arjen-lentz.livejournal.com/) and Mark Matthews (http://www.jroller.com/page/mmatthews ) of MySQL AB for their answers and explanations, and Jim Starkey and Technocation for their use of the audio from the July 2006 Boston User Group meeting with Jim Starkey.

Finally, episode 5 is here. In this episode, the first part in a two-part series about Falcon, the new storage engine provided by MySQL, we talk about what happens when you query a Falcon table, going over and explaining MVCC and the record cache. Next episode will go over the serial logs and indexes.

Direct play episode 5 at:
http://technocation.org/content/oursql-episode-5%3A-falcon%2C-part-1-0

Subscribe to the podcast by clicking:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=206806301

You can Direct download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Jim Starkey is a great speaker, and very funny to listen to – at one point he refers to a performance hit as a “performance surprise”. He’s also a piece of history – listen for his take on MVCC, which he invented.

Links:
Falcon features:
http://dev.mysql.com/doc/falcon/en/se-falcon-features.html

Falcon documentation
http://www.mysql.org/doc/refman/5.1/en/se-falcon.html

Special thanks to Arjen Lentz (http://arjen-lentz.livejournal.com/) and Mark Matthews (http://www.jroller.com/page/mmatthews ) of MySQL AB for their answers and explanations, and Jim Starkey and Technocation for their use of the audio from the July 2006 Boston User Group meeting with Jim Starkey.

The Sincerest Form of Flattery is Imitation

While MySQL customers have been bitterly complaining about the move to package support and rigorous testing of binaries into a paid package, Stephen Walli of Optaros has been thinking:

What if Microsoft SQL Server open sourced their codebase, provided support and testing of binaries in a paid package similar to MySQL Network, and “DB mashups” ensued?

http://stephesblog.blogs.com/my_weblog/2007/01/microsoft_and_m.html

It’s an interesting read to get you thinking. Most of my thought was, “that’d be neat….I wonder if folks would stop complaining about the MySQL Enterprise and Community models if that actually happened.”

While MySQL customers have been bitterly complaining about the move to package support and rigorous testing of binaries into a paid package, Stephen Walli of Optaros has been thinking:

What if Microsoft SQL Server open sourced their codebase, provided support and testing of binaries in a paid package similar to MySQL Network, and “DB mashups” ensued?

http://stephesblog.blogs.com/my_weblog/2007/01/microsoft_and_m.html

It’s an interesting read to get you thinking. Most of my thought was, “that’d be neat….I wonder if folks would stop complaining about the MySQL Enterprise and Community models if that actually happened.”

OurSQL Episode 4: Cluster From Down Under

This week’s podcast is an interview with MySQL’s Stewart Smith, software engineer for MySQL Cluster. Straight from the warm southern hemisphere, Stewart talks about Cluster. Because we gabbed on and on for 19 minutes, we’ve stripped the format down a bit, having the feature as pretty much the only segment.

You can download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Direct play this edition at:
http://technocation.org/content/oursql-episode-4%3A-cluster-down-under-0

Feature

Main cluster website:
http://www.mysql.com/cluster

Cluster documentation (in the manual):
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster.html

Cluster changes in MySQL 5.1:
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-5-1-changes.html

Cluster mailing list (for support, preferred):
http://lists.mysql.com/cluster

The cluster forum (with RSS feed):
http://forums.mysql.com/list.php?25

Acknowledgements

http://www.technocation.org

http://music.podshow.com

http://www.russellwolff.com

http://www.smallfishadventures.com/Home.html “The Thank you song” — Smallfish

Feedback

If you have any feedback about this podcast, or want to suggest topics to cover in future podcasts, please email

podcast@technocation.org

You can also:

Call the comment line at +1 617-674-2369

Or use Odeo to leave a voice mail through your computer:
http://odeo.com/sendmeamessage/Sheeri

Or use the Technocation forums:
http://technocation.org/forum

This week’s podcast is an interview with MySQL’s Stewart Smith, software engineer for MySQL Cluster. Straight from the warm southern hemisphere, Stewart talks about Cluster. Because we gabbed on and on for 19 minutes, we’ve stripped the format down a bit, having the feature as pretty much the only segment.

You can download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Direct play this edition at:
http://technocation.org/content/oursql-episode-4%3A-cluster-down-under-0

Feature

Main cluster website:
http://www.mysql.com/cluster

Cluster documentation (in the manual):
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster.html

Cluster changes in MySQL 5.1:
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-5-1-changes.html

Cluster mailing list (for support, preferred):
http://lists.mysql.com/cluster

The cluster forum (with RSS feed):
http://forums.mysql.com/list.php?25

Acknowledgements

http://www.technocation.org

http://music.podshow.com

http://www.russellwolff.com

http://www.smallfishadventures.com/Home.html “The Thank you song” — Smallfish

Feedback

If you have any feedback about this podcast, or want to suggest topics to cover in future podcasts, please email

podcast@technocation.org

You can also:

Call the comment line at +1 617-674-2369

Or use Odeo to leave a voice mail through your computer:
http://odeo.com/sendmeamessage/Sheeri

Or use the Technocation forums:
http://technocation.org/forum

Log Buffer #25: a Carnival of the Vanities for DBAs

December 29th, 2006 – by Sheeri Kritzer

Welcome to the 25th edition of Log Buffer, the DBA community’s Carnival of the Vanities-style blog of blogs about the database world.

This is the last Log Buffer of calendar year 2006. The database world seems to be a series of series lately, so let’s jump right in:

If, like me, you have no idea what doors and signals are in Solaris 10, you might want to read part 4 of Frank Mash‘s “Managing MySQL on Solaris 10”, entitled Solaris Doors and Signals.

On a more theoretical level, Random Notes describes lack of easy and complete access in the 3rd part of the series, “What stops a BI implementation from being a success?”

There’s always lots of spam in my inbox about enhancement of one thing or another. Chris Eaton uses enhanced views in An Expert’s Guide to DB2 Technology‘s series on using SQL to monitor DB2 9 with SQL scripts and enhanced views:

The similarly-named An Expert’s Guide to Oracle Technology has a series on Oracle Streams. This week part 2 describes how to Send CDC [Change Data Capture] Data to 9i Jonathan LewisOracle Scratchpad scratches out a second part to his Analysing Statspack.

Fulltext search is a pretty hot topic no matter what database you’re using, and zillablog has PostgreSQL full text search testing PART II. MySQL users beware — Kevin Burton‘s Feed Blog reveals a MySQL Bug with FLUSH TABLES and Fulltext Indexes in >=4.1.

If you’re the type that likes to type their own data by typing in new types, Radio Free Tooting toots their series on Programming with Oracle SQL TYPE constructs with Part 2.

The new year is almost upon us, and 2007 is when the US and Canada are affected by Daylight Savings Time pattern changes. Oracle’s Director of Applications Technology Integration Steven Chan has Documentation Available for Daily Saving Time 2007 Changes for Apps 11i.

And speaking of corny transitions between paragraphs, Oracle “springs ahead” with a USD $54 million grant to Indian polytechnical schools. CRM Chump has the scoop at Oracle Academy Gearing Up for Spring Semester in India.

In case you prefer Halloween over Christmas, Arjen Lentz gives users a “trick” instead of a “treat” in his Christmas Challenge: getting information out of INSERT/UPDATE in MySQL — the post contains how to get information out of a MySQL UPDATE, and the comments have Data Charmer Guiseppe Maxia INSERT answer.

Brian Duff of Duffblog has a link to a Flash Virtual Tour of Oracle’s “Unbreakable” Datacenter.

In the “How-to” department, Alexander Gladchenko writes about how to RESTORE onto RAW partition in SQL Server. Oracle is not Magic, it just takes years of experience writes about How to apply patch when adpatch is currently running? Oracle Online Help shows how to find the Execution plan of a running SQL statement. Step-by-step How to stop a DB2 Instance will remove even the most stubborn DB2 processes.

Insights of DB2 & Application Development takes a stance In Defence of Microsoft stating that while “DB2 is the first data server to offer programmers a choice of using Windows Vista”, Microsoft has made a patch available so that SQL Server may be run on Vista. How often do geeks defend Microsoft, anyway?

Reading between the lines of Tom Moertel‘s Never Store Passwords in a Database! it’s implicitly stated that companies should assume that customers use the same password regardless of security — Reddit should have assumed that people use the same password for Reddit as their e-mail and bank accounts, and secure their passwords accordingly. Explicitly, the comments state that “Never” means “As a general rule” and “Passwords” means “cleartext passwords”.

Firebird news reminds us that the 8th International Free Software Forum (fisl8.0, for “Free and Open Software”) call for papers is still open until January 7th.

Kevin Closson’s Oracle Blog debunks the latest benchmarking record set by Oracle on SAP, and also talks about the high availability of RAC. It’s always interesting to see the facts behind the facts, and how the scientific method can go astray when the background is revealed.

Log Buffer ends 2006 with some food for thought. Sean McCown’s Database Underground asks and answers, “Where Does Database Auditing Belong?

December 29th, 2006 – by Sheeri Kritzer

Welcome to the 25th edition of Log Buffer, the DBA community’s Carnival of the Vanities-style blog of blogs about the database world.

This is the last Log Buffer of calendar year 2006. The database world seems to be a series of series lately, so let’s jump right in:

If, like me, you have no idea what doors and signals are in Solaris 10, you might want to read part 4 of Frank Mash‘s “Managing MySQL on Solaris 10”, entitled Solaris Doors and Signals.

On a more theoretical level, Random Notes describes lack of easy and complete access in the 3rd part of the series, “What stops a BI implementation from being a success?”

There’s always lots of spam in my inbox about enhancement of one thing or another. Chris Eaton uses enhanced views in An Expert’s Guide to DB2 Technology‘s series on using SQL to monitor DB2 9 with SQL scripts and enhanced views:

The similarly-named An Expert’s Guide to Oracle Technology has a series on Oracle Streams. This week part 2 describes how to Send CDC [Change Data Capture] Data to 9i Jonathan LewisOracle Scratchpad scratches out a second part to his Analysing Statspack.

Fulltext search is a pretty hot topic no matter what database you’re using, and zillablog has PostgreSQL full text search testing PART II. MySQL users beware — Kevin Burton‘s Feed Blog reveals a MySQL Bug with FLUSH TABLES and Fulltext Indexes in >=4.1.

If you’re the type that likes to type their own data by typing in new types, Radio Free Tooting toots their series on Programming with Oracle SQL TYPE constructs with Part 2.

The new year is almost upon us, and 2007 is when the US and Canada are affected by Daylight Savings Time pattern changes. Oracle’s Director of Applications Technology Integration Steven Chan has Documentation Available for Daily Saving Time 2007 Changes for Apps 11i.

And speaking of corny transitions between paragraphs, Oracle “springs ahead” with a USD $54 million grant to Indian polytechnical schools. CRM Chump has the scoop at Oracle Academy Gearing Up for Spring Semester in India.

In case you prefer Halloween over Christmas, Arjen Lentz gives users a “trick” instead of a “treat” in his Christmas Challenge: getting information out of INSERT/UPDATE in MySQL — the post contains how to get information out of a MySQL UPDATE, and the comments have Data Charmer Guiseppe Maxia INSERT answer.

Brian Duff of Duffblog has a link to a Flash Virtual Tour of Oracle’s “Unbreakable” Datacenter.

In the “How-to” department, Alexander Gladchenko writes about how to RESTORE onto RAW partition in SQL Server. Oracle is not Magic, it just takes years of experience writes about How to apply patch when adpatch is currently running? Oracle Online Help shows how to find the Execution plan of a running SQL statement. Step-by-step How to stop a DB2 Instance will remove even the most stubborn DB2 processes.

Insights of DB2 & Application Development takes a stance In Defence of Microsoft stating that while “DB2 is the first data server to offer programmers a choice of using Windows Vista”, Microsoft has made a patch available so that SQL Server may be run on Vista. How often do geeks defend Microsoft, anyway?

Reading between the lines of Tom Moertel‘s Never Store Passwords in a Database! it’s implicitly stated that companies should assume that customers use the same password regardless of security — Reddit should have assumed that people use the same password for Reddit as their e-mail and bank accounts, and secure their passwords accordingly. Explicitly, the comments state that “Never” means “As a general rule” and “Passwords” means “cleartext passwords”.

Firebird news reminds us that the 8th International Free Software Forum (fisl8.0, for “Free and Open Software”) call for papers is still open until January 7th.

Kevin Closson’s Oracle Blog debunks the latest benchmarking record set by Oracle on SAP, and also talks about the high availability of RAC. It’s always interesting to see the facts behind the facts, and how the scientific method can go astray when the background is revealed.

Log Buffer ends 2006 with some food for thought. Sean McCown’s Database Underground asks and answers, “Where Does Database Auditing Belong?

OurSQL Episode 3: Your Database on ACID

This week’s feature talks about ACID compliance, what it is, and how MySQL achieves it.

If folks have ideas or suggestions for content, please let me know by e-mailing podcast@sheeri.com or by leaving a comment.

You can Direct download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Direct play this edition at:
http://technocation.org/content/oursql-episode-3%3A-your-database-acid

News
Download MySQL Turbo Manager Free Edition at: http://www.mentattech.com/themes/mentat/download.html

Wireless providers prefer MySQL over Oracle, Microsoft SQL Server over both:

http://www.crn.com/sections/breakingnews/breakingnews.jhtml?articleId=196700062

Learning Resource

Artful Software’s list of common queries. They also have an interesting e-book available, called “Get it Done with MySQL 5.0”.

http://www.artfulsoftware.com/queries.php

DATEDIFF(), DAYOFWEEK() functions

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

Promo

This week’s promotion comes from Geek Fu at http://www.geekfuactiongrip.com

Feature

Concurrency and Isolation Levels
http://sheeri.net/index.php?p=123

Acknowledgements

http://www.technocation.org

http://music.podshow.com

http://www.russellwolff.com

http://www.smallfishadventures.com/Home.html “The Thank you song” — Smallfish

Feedback

If you have any feedback about this podcast, or want to suggest topics to cover in future podcasts, please email

podcast@technocation.org This email address is being protected from spam bots, you need Javascript enabled to view it

You can also:

Call the comment line at +1 617-674-2369

Or use Odeo to leave a voice mail through your computer:
http://odeo.com/sendmeamessage/Sheeri

Or use the Technocation forums:
http://technocation.org/forum



This week’s feature talks about ACID compliance, what it is, and how MySQL achieves it.

If folks have ideas or suggestions for content, please let me know by e-mailing podcast@sheeri.com or by leaving a comment.

You can Direct download all the oursql podcasts at:
http://technocation.org/podcasts/oursql/

Direct play this edition at:
http://technocation.org/content/oursql-episode-3%3A-your-database-acid

News
Download MySQL Turbo Manager Free Edition at: http://www.mentattech.com/themes/mentat/download.html

Wireless providers prefer MySQL over Oracle, Microsoft SQL Server over both:

http://www.crn.com/sections/breakingnews/breakingnews.jhtml?articleId=196700062

Learning Resource

Artful Software’s list of common queries. They also have an interesting e-book available, called “Get it Done with MySQL 5.0”.

http://www.artfulsoftware.com/queries.php

DATEDIFF(), DAYOFWEEK() functions

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

Promo

This week’s promotion comes from Geek Fu at http://www.geekfuactiongrip.com

Feature

Concurrency and Isolation Levels
http://sheeri.net/index.php?p=123

Acknowledgements

http://www.technocation.org

http://music.podshow.com

http://www.russellwolff.com

http://www.smallfishadventures.com/Home.html “The Thank you song” — Smallfish

Feedback

If you have any feedback about this podcast, or want to suggest topics to cover in future podcasts, please email

podcast@technocation.org This email address is being protected from spam bots, you need Javascript enabled to view it

You can also:

Call the comment line at +1 617-674-2369

Or use Odeo to leave a voice mail through your computer:
http://odeo.com/sendmeamessage/Sheeri

Or use the Technocation forums:
http://technocation.org/forum