You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,10 @@ Zo_hpnDxkOsAWLk1tIS6DA
73
73
## Sequential Guids 🔥
74
74
`guid` includes two special types `GuidPG` and `GuidSS` optimized for use as database primary keys (PostgreSQL and SQL Server). Their time-ordered composition helps prevent index fragmentation and improves `INSERT` performance compared to fully random Guids. Note that sequential sorting is only across `time.Now()` timestamp precision.
75
75
76
-
***`guid.NewPG()`**: Generates a `GuidPG`, which is sortable in **PostgreSQL**. It is structured as `[8-byte timestamp][8 random bytes]`.
77
-
***`guid.NewSS()`**: Generates a `GuidSS`, which is sortable in **SQL Server**. It is structured as `[8 random bytes][8-byte SQL Server-ordered timestamp]`.
76
+
***`guid.NewPG()`**: Generates a `GuidPG`, which is sortable in **PostgreSQL**.
77
+
- It is structured as `[8-byte timestamp][8 random bytes]`.
78
+
***`guid.NewSS()`**: Generates a `GuidSS`, which is sortable in **SQL Server**.
79
+
- It is structured as `[8 random bytes][8-byte SQL Server-ordered timestamp]`.
78
80
*`.Timestamp()` on `GuidPG`/`GuidSS` returns Guid creation time as UTC `time.Time`.
79
81
80
82
Both `GuidPG` and `GuidSS` are nearly as fast as `guid.New()`. They can be used as a standard `Guid` and support the same interfaces.
@@ -117,7 +119,7 @@ GFEU88w5PqTsYX0kcZzL6Q 185114f3cc393ea4ec617d24719ccbe9 yFIlRwKZJNo-pBhRFPPMOQ c
117
119
* If you must keep using `google/uuid`, use `guid` to increase performance by **2~4x**:
0 commit comments