Because of its importance, we have to give special consideration to how we select our primary keys. The foundation for a table in a relational database is the primary key. Relational databases are highly intertwined, so one small change can have unexpected, cascading effects. Tps = 65269.Changing the schema for large relational databases costs companies millions of dollars every year. Tps = 81562.002058 (without initial connection time) Tps = 83478.089558 (without initial connection time) Number of failed transactions: 0 (0.000%) Number of transactions actually processed: 1600000/1600000 Number of transactions per client: 200000 It is nearly as fast as creating the native UUIDs! pgbench -client=8 -jobs=8 -transactions=200000 -file=$.sql I also had a need for v7 UUIDs, so I wrote a tiny C extension to create them. The world of unique identifiers has been fascinating, looking forward to UUID v7 being an official spec! Tps = 31357.427361 (without initial connection time) Tps = 32798.220795 (without initial connection time) Tps = 31379.895607 (without initial connection time) Tps = 31049.899167 (without initial connection time) Tps = 43681.715582 (without initial connection time) Number of transactions actually processed: 800000/800000 Number of transactions per client: 100000 OS: Fedora Linux 36 (Workstation Edition) x86_64 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE Thanks this has been super helpful! I'm going to start using v7 in a side project! I'm probably worrying more about performance than I should, but here's another high-load benchmark for revision 7 and revision 12 + the native UUID v4 generator if anyone is interested: - Benchmark run on THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Uuid_bytes = set_byte(uuid_bytes, 7, microseconds:: bit( 8):: int) Microseconds = (cast(extract(microseconds from timestamp):: int - (floor(extract(milliseconds from timestamp)):: int * 1000) as double precision) * 4. Unix_ts_ms = substring(int8send(floor(extract(epoch from timestamp) * 1000):: bigint) from 3) Generate a custom UUID v8 with microsecond precisionĬreate or replace function uuid_generate_v8() Uuid_bytes = overlay(uuid_bytes placing unix_ts_ms from 1 for 6) Uuid_bytes = uuid_send(gen_random_uuid()) use random v4 uuid as starting point (which has the same variant we need) Unix_ts_ms = substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000):: bigint) from 3) Create or replace function uuid_generate_v7()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |