Blog » Blog Entry

Oracle's Silly Sequence Cache

April 9, 2008

The more I use Oracle the more I appreciate the lightweight nature of MySQL and even PostgreSQL for that matter. Right tool for the right job I guess :)

My latest Oracle issue seemed fairly odd at first. The issue was that I needed sequential numbers from my sequence, but Oracle was giving them to me in what seemed to be blocks of 20 at a time. Instead of 1.. 2.. 3.. 4, it would return 1.. 21.. 41.. and so on. Here's the fix, in a Rails migration since that's where I applied it:

class FixSeq < ActiveRecord::Migration

  def self.up
    execute "ALTER SEQUENCE USERS_SEQ NOCACHE"
  end

  def self.down
  end

end

My co-worker bud Bill helped me figure it out. Aside from being an awesome bassist, he's also an Oracle Guru.

Tags: rubyonrails, oracle

« Christopher Hitchens Recommended Books Two Rivers Ford in Nashville, TN are crooks »

Thanks!

By: Bill Graham <liam at liamgraham dot com>

Posted: 3 months ago

Dude, I checked my website traffic, and I've gotten hits from this. ;)

Thanks for the link and compliment...

Bill

Add a comment:

Title:

Comment:

Name:

Email: