Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support to ULID column type #3699

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

devajmeireles
Copy link

Based on several studies and personal tests, we can prove the effectiveness of ulid columns instead of uuid when talking about a large volume of data.

A package like this tends to persist a thousand of data in the database since all the media of an entire application is persisted in a table. Some public studies point to abstracts where ULID is advantageous in these cases.

"ULID is often considered superior to UUID when ordering and efficiency are important. It is lexicographically orderable, which makes it easier to organize data in chronological order, something that UUIDs cannot do efficiently. In addition, ULID is more compact, at 26 characters, compared to UUID's 36 characters, making it easier to read and transmit. Embedding a timestamp in ULID means that IDs generated at close points in time will be ordered in a natural way, which can improve database performance by minimizing index fragmentation. While UUIDs are widely used and supported, ULID offers specific advantages in terms of temporal ordering and storage efficiency, making it a preferred choice in many systems that prioritize these characteristics."

A good read is here: https://medium.com/@sammaingi5/uuid-vs-ulid-how-ulid-improves-write-speeds-d16b23505458


This PR is an attempt to implement a configuration that allows ULID to be used instead of UUID.

@devajmeireles devajmeireles marked this pull request as draft August 24, 2024 05:50
@devajmeireles
Copy link
Author

Hey, @freekmurze ! I'd like to know your opinion on this before I continue with the PR :D There doesn't seem to be any breaking changes, but I'd like your opinion on whether I should move forward because it's something interesting in your eyes.

@patinthehat
Copy link
Collaborator

@devajmeireles please feel free to continue with this PR. I'm happy to review it once it's ready 👍 Thank you!

@patinthehat patinthehat self-requested a review September 21, 2024 11:05
@devajmeireles devajmeireles marked this pull request as ready for review September 22, 2024 04:19
@devajmeireles
Copy link
Author

@devajmeireles please feel free to continue with this PR. I'm happy to review it once it's ready 👍 Thank you!

Hey, @patinthehat ! Thanks for your feedback. I think the PR is ready for review. Feel free to review it and point out anything misaligned or incorrect so I can adjust it.

Copy link
Collaborator

@patinthehat patinthehat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the docs to explain the new configuration setting/environment variable. Other than that and one other minor change, looks good!

config/media-library.php Outdated Show resolved Hide resolved
src/MediaCollections/Models/Media.php Outdated Show resolved Hide resolved
@devajmeireles
Copy link
Author

Hey, @patinthehat ! I applied all your suggestions. I also tried searching for UUID (or variations, like: uuid) in the docs, to write something special for someone who wants to use ULID instead of UUID, but the docs don't mention anything related to that, so I just updated the installation.md docs with the new configuration value.

Copy link
Collaborator

@patinthehat patinthehat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devajmeireles Thanks for the updates! Would you mind adding an additional markdown file in "advanced usage" that explains the configuration option and what it does when true and false?

@@ -14,6 +14,11 @@
*/
'max_file_size' => 1024 * 1024 * 10, // 10MB

/*
* Determiner if the media table should use ULID instead of UUID.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Typo in "Determine" 😄

@@ -51,6 +51,11 @@ return [
* Adding a larger file will result in an exception.
*/
'max_file_size' => 1024 * 1024 * 10,

/*
* Determiner if the media table should use ULID instead of UUID.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants