<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Stored Function to generate Sequences</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/</link>
	<description>Everything about MySQL Performance</description>
	<pubDate>Tue, 14 Oct 2008 06:54:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Using Multiple Sequences in a Table &#171; Everything MySQL</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-355572</link>
		<dc:creator>Using Multiple Sequences in a Table &#171; Everything MySQL</dc:creator>
		<pubDate>Tue, 16 Sep 2008 18:32:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-355572</guid>
		<description>[...] issues.  After lot of trials, debates and finally referring Planet MySQL, I went ahead with this suggestion by Peter from MySQL Performance Blog and some help from here. CREATE TABLE sequences ( event_id [...]</description>
		<content:encoded><![CDATA[<p>[...] issues.  After lot of trials, debates and finally referring Planet MySQL, I went ahead with this suggestion by Peter from MySQL Performance Blog and some help from here. CREATE TABLE sequences ( event_id [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Huff</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-337671</link>
		<dc:creator>Justin Huff</dc:creator>
		<pubDate>Thu, 31 Jul 2008 01:22:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-337671</guid>
		<description>I typically see the update step written like:
UPDATE sequence SET nValue=last_insert_id(nValue+1) WHERE strName=?

I'd like to allow servers the option of asking for more than one id per call by moving the increment step outside the last_insert_id:
UPDATE sequence SET nValue=last_insert_id(nValue)+? WHERE strName=?

The value in the table shifts from being the 'last id handed out' to 'the next id to hand out'.  That way requesters don't need to know how big the last block was.

Am I missing something here? 
Thanks!</description>
		<content:encoded><![CDATA[<p>I typically see the update step written like:<br />
UPDATE sequence SET nValue=last_insert_id(nValue+1) WHERE strName=?</p>
<p>I&#8217;d like to allow servers the option of asking for more than one id per call by moving the increment step outside the last_insert_id:<br />
UPDATE sequence SET nValue=last_insert_id(nValue)+? WHERE strName=?</p>
<p>The value in the table shifts from being the &#8216;last id handed out&#8217; to &#8216;the next id to hand out&#8217;.  That way requesters don&#8217;t need to know how big the last block was.</p>
<p>Am I missing something here?<br />
Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Links for Wed 7 May 2008 - Joseph Scott&#8217;s Blog</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-296732</link>
		<dc:creator>Links for Wed 7 May 2008 - Joseph Scott&#8217;s Blog</dc:creator>
		<pubDate>Thu, 08 May 2008 16:52:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-296732</guid>
		<description>[...] Stored Function to generate Sequences &#124; MySQL Performance Blog - You could combine this with an INSERT trigger and get even more auto_increment like functionality.  Tags: database mysql sequence [...]</description>
		<content:encoded><![CDATA[<p>[...] Stored Function to generate Sequences | MySQL Performance Blog - You could combine this with an INSERT trigger and get even more auto_increment like functionality.  Tags: database mysql sequence [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-265378</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Fri, 04 Apr 2008 01:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-265378</guid>
		<description>Arjen,

Indeed insert on dup key updates saves you from initialization though I'm wondering what way would be the faster.
Though I guess there would not be any significant difference here.</description>
		<content:encoded><![CDATA[<p>Arjen,</p>
<p>Indeed insert on dup key updates saves you from initialization though I&#8217;m wondering what way would be the faster.<br />
Though I guess there would not be any significant difference here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjen Lentz</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-265373</link>
		<dc:creator>Arjen Lentz</dc:creator>
		<pubDate>Fri, 04 Apr 2008 01:36:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-265373</guid>
		<description>kL, even with a sequence generator stored in MyISAM you would not see the same number in different threads.</description>
		<content:encoded><![CDATA[<p>kL, even with a sequence generator stored in MyISAM you would not see the same number in different threads.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjen Lentz</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-265372</link>
		<dc:creator>Arjen Lentz</dc:creator>
		<pubDate>Fri, 04 Apr 2008 01:34:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-265372</guid>
		<description>Here was mine http://arjen-lentz.livejournal.com/34627.html (been there for a few years ;-)
Also incorporates a trigger so the app can be oblivious it's not an AUTO_INCREMENT column.</description>
		<content:encoded><![CDATA[<p>Here was mine <a href="http://arjen-lentz.livejournal.com/34627.html" rel="nofollow">http://arjen-lentz.livejournal.com/34627.html</a> (been there for a few years <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
Also incorporates a trigger so the app can be oblivious it&#8217;s not an AUTO_INCREMENT column.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-264838</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Thu, 03 Apr 2008 15:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-264838</guid>
		<description>kL,

Yes you can use char here or even better ENUM or INT if you're hunting for last 0.01% of performance. 

Regarding Innodb Tables it still works because updates to the same rows will be serialized and so you can't get same values in different threads.</description>
		<content:encoded><![CDATA[<p>kL,</p>
<p>Yes you can use char here or even better ENUM or INT if you&#8217;re hunting for last 0.01% of performance. </p>
<p>Regarding Innodb Tables it still works because updates to the same rows will be serialized and so you can&#8217;t get same values in different threads.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toby</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-264769</link>
		<dc:creator>Toby</dc:creator>
		<pubDate>Thu, 03 Apr 2008 14:19:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-264769</guid>
		<description>This technique is perfectly safe with InnoDB tables.</description>
		<content:encoded><![CDATA[<p>This technique is perfectly safe with InnoDB tables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kL</title>
		<link>http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-264410</link>
		<dc:creator>kL</dc:creator>
		<pubDate>Thu, 03 Apr 2008 09:49:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2008/04/02/stored-function-to-generate-sequences/#comment-264410</guid>
		<description>If you change sequence name from varchar to char you'll get fixed-width table (slightly faster).

It's probably important that sequences are in MyISAM table that doesn't support transactions - otherwise different threads would be isolated (I in ACID) and could come up with the same sequence value!</description>
		<content:encoded><![CDATA[<p>If you change sequence name from varchar to char you&#8217;ll get fixed-width table (slightly faster).</p>
<p>It&#8217;s probably important that sequences are in MyISAM table that doesn&#8217;t support transactions - otherwise different threads would be isolated (I in ACID) and could come up with the same sequence value!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
