uuid

Is COMB GUID a good idea with Rails 3.1 if I use GUIDs for primary keys?

六眼飞鱼酱① 提交于 2019-11-30 18:24:49
问题 I'm using Rails 3.1 with PostgreSQL 8.4. Let's assume I want/need to use GUID primary keys. One potential drawback is index fragmentation. In MS SQL, a recommended solution for that is to use special sequential GUIDs. One approach to sequential GUIDs is the COMBination GUID that substitutes a 6-byte timestamp for the MAC address portion at the end of the GUID. This has some mainstream adoption: COMBs are available natively in NHibernate (NHibernate/Id/GuidCombGenerator.cs). I think I've

PostgreSQL UUID type performance

你说的曾经没有我的故事 提交于 2019-11-30 18:04:47
I'm not trying to restart the UUID vs serial integer key debate. I know there are valid points to either side. I'm using UUID's as the primary key in several of my tables. Column type: "uuidKey" text NOT NULL Index: CREATE UNIQUE INDEX grand_pkey ON grand USING btree ("uuidKey") Primary Key Constraint: ADD CONSTRAINT grand_pkey PRIMARY KEY ("uuidKey"); Here is my first question; with PostgreSQL 9.4 is there any performance benefit to setting the column type to UUID? The documentation http://www.postgresql.org/docs/9.4/static/datatype-uuid.html describes UUID's, but is there any benefit aside

generate UUID of long type

六月ゝ 毕业季﹏ 提交于 2019-11-30 14:18:15
Please give me sample code to generate UUID of long type in java without using timestamp. Thanks A real UUID is 128 bits. A long is 64 bits. This is not just pedantry. UUID stands for Universal Unique IDentifier. The "universal uniqueness" of the established UUID schemes are based on: encoding a MAC address and a timestamp, encoding a hash of a DNS name and a timestamp, or using a 122 bit random number ... which is large enough that the probability of a collision is very very small. With 64 bits, there are simply not enough bits for "universal uniqueness". For instance, the birthday paradox

How to generate a UUIDv4 in MySQL?

六月ゝ 毕业季﹏ 提交于 2019-11-30 13:11:31
问题 MySQL's UUID function returns a UUIDv1 GUID. I'm looking for an easy way to generate random GUIDs (i.e. UUIDv4) in SQL. 回答1: I've spent quite some time looking for a solution and came up with the following mysql function that generates a random UUID (i.e. UUIDv4) using standard MySQL functions. I'm answering my own question to share that in the hope that it'll be useful. -- Change delimiter so that the function body doesn't end the function declaration DELIMITER // CREATE FUNCTION uuid_v4()

Linux下swap分区没有UUID解决办法

江枫思渺然 提交于 2019-11-30 11:50:44
前几天在windows下使用分区调整软件更改了一下我Linux下swap分区的大小, 之后再进入Linux时发现swap分区无法挂载。打开/etc/fstab查看一下挂载配置,发现挂载分区时使用的都是uuid而不是直接使用像/dev/sda1这样的完整路径。看了一下文件里面交换分区的UUID,然后又用blkid查看我原来交换分区的uuid, blkid /dev/sdb3 结果: /dev/sdb3: TYPE="swap" 奇怪了,竟然没有UUID。百度谷歌一起上,看了一些文章后总结出了一点结论:这个UUID是Linux系统给硬盘分区分配的唯一标志符,它是在 Linux下由系统自动生成的。由于我在Windows下调整过分区,而Windows系统不会生成UUID,所以这个分区的UUID号就丢失了。 接下来的工作当然是要重新生成了。 第一步:安装Gparted 我们需要安装一个软件,Gparted,Ubuntu下可以直接使用sudo apt-get install gparted命令安装。 第二步:重新格式化swap分区 安装完毕后在命令行中输入gparted启动软件(需要root权限)。如果你有多个硬盘,可能需要在“Gparted">”设备“中选择你 的硬盘。之后在下面分区列表中找到你的Swap分区,选中它右击,选择“格式化为”->“linux-swap”

Android: Use UUID as primary key in SQLite

人盡茶涼 提交于 2019-11-30 10:56:44
问题 My app needs to get synced with other app users (on there own devices). I also want to support offline editing, that are synchronized to the other collaborative users when the user gets connected to the internet. So the User A changes (while he is offline) some data (in ohter words he would update database entries) or add new records to the database. When User A gets connected to the internet, all changes and new records are delivered to the other collaborative Users. So User B will get the

UUID to unique integer id?

五迷三道 提交于 2019-11-30 10:42:14
I was wondering what the easiest way to convert a UUID to a unique integer would be? I have tried using the hash code but people tell me that it is not going to always be unique if i use the hash code? So what is the easiest way? Is the hash code unique? You are going to have a problem since the UUID is 128 bits and the int is only 32bit. You'll either have to accept the risk of collisions and try to fudge it to a smaller space ( hashCode is probably a good way to do that) or find an alternative (use the UUID directly, map to a BigInteger - difficult to tell without knowing why) pgras

How to identify unique user?

邮差的信 提交于 2019-11-30 09:13:33
Question How can you determine if a user is unique or not? I understand there are many ways to do this using cookies, but what about methods that don't use cookies? For example, go to Urban Dictionary and click one of the up/down vote buttons. Even if you delete your cookies and come back to the page, you will not be allowed to cast a vote on the same definition. How do they do this? Purpose Eventually, I'd like to use this unique user detection method on a site where users create accounts. New signups are given a type of "reward" and I want to prevent people from creating multiple accounts in

UUID versus auto increment number for primary key

坚强是说给别人听的谎言 提交于 2019-11-30 08:34:21
Why should I choose UUID over an auto increment number for my entity's primary key? What are the pros and cons? Andrey and Mjg both had good points, but I would add a related performance issue that is significant. With the decoupling of database and key generation also allows applications that have complex relationships between objects to create them all with the keys in place, so that bulk inserts are possible. In the case of auto-increment, all of the objects that own relationships (ie the tables with foreign keys) have to wait for the other side of the relationship (ie the table the foreign

default value of GUID in for a column in mysql

此生再无相见时 提交于 2019-11-30 08:16:39
问题 I want a column to default to a GUID, so if I am doing an insert and I don't explicitly set the value, I want it to default to a new GUID value. how can I do this? 回答1: Being that UUID() isn't accepted as a DEFAULT constraint, you need to use a trigger. This one sets the value for the NEW_TABLE.uuid column: delimiter $$ CREATE DEFINER=`root`@`localhost` TRIGGER `example`.`newid` BEFORE INSERT ON `example`.`new_table` FOR EACH ROW BEGIN SET NEW.`uuid` = UUID(); END $$ 回答2: Previous answer is