Replies: 1 comment 2 replies
-
PostgreSQL (or the driver) natively converts from the text UUID to the actual
I'm guessing the conversion from string to Effectively your
If using SQLAlchemy, you can do this automatically with a new SA type:
|
Beta Was this translation helpful? Give feedback.
-
I'm looking into performance enhancements to a few apps I have going by switching from standard
uuid.uuid4
generated primary keys to sneaking in ULID values, thinking the lexicographical sortable ULID will increase efficiency of transactions.In the app we use
str(uuid.uuid4())
on the client side to build the Postgres inserts/updates. My understanding (from the docs) is thatULID().to_uuid4()
would be destructive to the underlying byte-order, and so would in-effect just be a UUIDv4. But that usingULID().to_uuid()
would look like a valid UUID as far as Postgres is concerned, but the underlying bytes would be friendlier to the database's b-tree Index and page-cache.I have a well resourced Postgres instance though that I've been doing performance testing on the last two days and I cannot detect any significant different in throughput of inserts or updates. I feel like I'm missing something though. Should I not be able to insert with
str(ULID.to_uuid())
or have I missed something?Beta Was this translation helpful? Give feedback.
All reactions