On Apr 4, 5:01 am, DavidJ <[email protected]> wrote:
> So, if you had a trillion DB servers, auto_increment could never work
> because to determine which is the next id would require querying them
> all to figure out what the largest existing id is (or, alternatively,
> keeping the 'next id' stored in a central place - which will be a
> performance bottleneck when a trillion servers have to hit it up for
> every insert).

I think master master mysql setups do things slightly differently, you
can set things up so that with (for example)
 3 servers one of them has auto increment keys that look like 3n, the
next one 3n+1, and the third 3n+2, so a given server only needs to
track the auto increment it last assigned. No idea how far this
scales, even with 64bit ids you would't have much room with 10^12
servers
>
> However, the :primary doesn't seem to work (perhaps is invalid) and
> the table generated doesn't have a primary key.  I can use add_index
> to add a :unique index, but it isn't primary.  Obviously, I'll need
> some hooks to generate the UUIDs - I've delved into that part.

:primary_key is hardwired to be an integer on mysql, and I believe on
on postgres and other dbs too. If you want a primary key of a
different type I think you'll need to add the column as whatever data
type you want and then run a lump of sql to mark it as the primary key
>
> So, can Rails really handle this in a clean way and have scaffolding
> work etc?  How?  Can someone kindly clue me into what I need in the
> migration, model class and anywhere else?  I'd prefer to avoid DB-
> specific SQL execution (while I'm testing this on MySQL, that
> obviously isn't a distributed scalable technology so I'll be using a
> distributed store ultimately).

If that is your end goal you might not want to spend too much time
with activerecord since it only really does SQLish things (ie not
mongodb, couchdb etc.)

Fred

> I'd also like some tables to have natural (domain specific) primary
> key values, a related though perhaps separate issue (and less
> critical).
>
> I've achieved similar on another project using Grails by writing a JPA
> implementation.  I'm really hoping Rails can do this without having
> the source hacked.
>
> Any help or pointers are greatly appreciated.
>
> Cheers,
> -David.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to