Preventing Row-by-Row Flush In YugabyteDB With UUIDv7 Function
When creating user-defined functions in YugabyteDB, use simple expressions to avoid row-by-row flushing (Write Buffering). Avoid `generate_series` or `with recursive`. Use `create or replace function` with a simple SQL expression.
When creating a user-defined function for inserts, such as one that generates a default value, you should ensure it does not cause a row-by-row flush (Write Buffering) in YugabyteDB. The function must be a simple expression (no generate_series, no with recursive). Here is an example of how to generate a UUIDv7. I've developed a function that generates a UUIDv7 from a timestamp (defaulting to now()) and a shift interval from this timestamp (defaulting to no shift): create or replace function uuid7(shift_interval interval DEFAULT '0 milliseconds', p_timestamp timestamp with time zone default no...