Skip to content

# Tag: NoSQL

## On generating unique IDs using LAST_INSERT_ID() and other tools

MySQL memcached NoSQL Performance Query Cache February 2, 2011February 2, 2011

There’s a trick for using LAST_INSERT_ID() to generate sequences in MySQL. Quoting from the Manual:

> 1. Create a table to hold the sequence counter and initialize it:

>        mysql> CREATE TABLE sequence (id INT NOT NULL);
>        mysql> INSERT INTO sequence VALUES (0);

> 2. Use the table to generate sequence numbers like this:

>        mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1);
>        mysql> SELECT LAST_INSERT_ID();

This trick calls for trouble.

#### Contention

A customer was using this trick to generate unique session IDs for his JBoss sessions. These IDs would eventually be written back to the database in the form of log events. Business go well, and one day the customer adds three new JBoss servers (doubling the amount of webapps). All of a sudden, nothing works quite as it used to. All kinds of queries take long seconds to complete; load average becomes very high. Continue reading » “On generating unique IDs using LAST_INSERT_ID() and other tools”

## Tales of the Trade #3: MySQL vs. NoSQL

MySQL Humor NoSQL April 19, 2010April 21, 2010

Apparently the message from the comic below was not well conceived.

Following the strip I’ve added some spoiler notes.

This is not about bashing NoSQL. Apparently some people feel this way.

This is about:

- Trying to judge/analyze NoSQL as if it were a single entity, thereby asking “should I use MySQL or NoSQL”?
- The fact Wikipedia defines NoSQL as a “movement” (who’s the leader?)
- The fact that people are still arguing on how “MySQL” should be pronounced.