diff --git a/examples/ndistinct/README.md b/examples/ndistinct/README.md index a8e52c0..212ab79 100644 --- a/examples/ndistinct/README.md +++ b/examples/ndistinct/README.md @@ -1,3 +1,5 @@ +Inspired by a sql script authored by Jim Finnerty and proposed to the PostgreSQL hackers mailing list, https://www.postgresql.org/message-id/1548191628417-0.post%40n3.nabble.com + ## Calculating N-distinct elements During ```ANALYZE```, the ```n_distinct``` value of a column is calculated as either a fixed value or a ratio of the number of distinct values over the total number of rows. The fixed value is always represented as a positive number, while the ratio will be represented as a negative number. This value is visible in the n_distinct column of the ```pg_stats``` catalog view and used by the PostgreSQL query optimizer for planning. For more, refer to the PostgreSQL [[documentation]](https://www.postgresql.org/docs/current/view-pg-stats.html]). diff --git a/examples/uuid_v7/README.md b/examples/uuid_v7/README.md index 7ee932b..98aa7fc 100644 --- a/examples/uuid_v7/README.md +++ b/examples/uuid_v7/README.md @@ -1,3 +1,5 @@ +Inspired by a patch authored by Andrey Borodin and proposed to the PostgreSQL hackers mailing list, https://www.postgresql.org/message-id/CAAhFRxitJv%3DyoGnXUgeLB_O%2BM7J2BJAmb5jqAT9gZ3bij3uLDA%40mail.gmail.com. + ## Generating a UUID v7 [Universally unique identifiers](https://en.wikipedia.org/wiki/Universally_unique_identifier) (UUIDs) are a data type frequently used as primary keys due to their uniqueness property. Historically, one of the most popular methods of generating UUIDs was UUID v4, which randomly generated the UUID. However, this often caused poor index locality, as compared to a monotonically increasing integer, and can impact how quickly users can retrieve rows from a database. To improve this experience, [UUID v7](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#name-uuid-version-7) was proposed, which stores a portion of a UNIX timestamp in the first 48-bits before allowing for the generation of random data.