[Dbix-class] (OT) Do you use UUIDs?

John Napiorkowski jjn1056 at yahoo.com
Mon Jul 2 14:33:39 GMT 2007


--- "Christopher H. Laco" <claco at chrislaco.com> wrote:

> Ben Staude wrote:
> > Hi all,
> > 
> > this is slightly off-topic, so if you know a
> better place for it, please let 
> > me know. On the other hand, the guys here know a
> lot about using Databases 
> > with perl...
> > 
> > I'm wondering whether to use UUID instead of
> auto-increment pk in my database 
> > (dbic, sqlite) app. Right now, I'm fine with the
> integer keys, but there 
> > might eventually come the day that I want to
> "split" and "merge" the 
> > database. As far as I understood, there's no
> better way to be prepared for 
> > such things than uuid-keys.
> 
> uuid keys are reat for offsite, and other forms of
> replication where
> both side may be edited.
> 
> > 
> > What are the drawbacks I have to expect if
> switching to uuid-keys? I know I'd 
> 
> They are just slower than ints. Although with the
> proper indexes, I say
> you'll run into other performance issues in your
> apps lon before uuids
> become your problem.
> 
> 
> > have to add a dependency to Data::UUID (btw, is it
> the one to use?), but I 
> 
> DBIx::Class::UUIDColumns and ::UUIDMaker. IT takes
> care of usin the
> first available uuid eneration module (Data::UUID,
> UUID, Win32::UUIDen,
> APR::UUID, etc)
> 
> 
> > can't estimate the performance impact on inserts
> (not that critical) and 
> > selects (< 100,000 records in the db). Disk space
> shouldn't be an issue.
> > 
> > Do you all use it everywhere, or do you avoid it
> wherever you can? Maybe 
> > there's some kind of "best practice" established?
> Using uuid-keys sounds 
> > reasonable, but I wonder why they don't appear in
> every schema on the list...
> > 
> > Thank you very much for any hints,
> > 
> > Ben
> 
> If I'm in a replication situation, I always use
> uuids. It's just easier
> than setting up auto increcement ranes for each
> replicaiton source.
> Personally, my hate aainst autoinc ints has been old
> versions of mssql.
> It wasn't terribly uncommon to have autoinc seed
> counts to be reset
> during table alterations, alowing ids to be enerated
> in gaps where
> records have been deleted. I like using uuids also
> when I want ids to be
> unique across tables...maybe for the purposes of
> logging.
> 
> I also like using uuids as pks for url purposes.
> When I pass them in the
> urls or in forms, they aren't guessable, like ints
> are for trying to
> pull up other records.
> 
> Just my $0.02 worth.
> 
> -=Chris

I also like to use uuids as PK as well, however when I
am using them as PK's I prefer to use a custom domain
and type in postgres to create them rather than use
the DBIC plugin.  That way if my admins need to access
the database directly and make changes (like add rows,
etc.) or if I need to have the DB used by applications
not using DBIC I don't need to worry that the PK's
will get messed up.

I do this when I get to use Postgresql.  When I have
to use Mysql I just go with oldschool serial PKs.

--john



> 
> > _______________________________________________
> List:
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN:
>
http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
http://www.mail-archive.com/dbix-class@lists.rawmode.org/



       
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=list&sid=396545433



More information about the Dbix-class mailing list