![]() Retrieve a million uuids via the pecl extension. $uuid = db_result(db_query("SELECT UUID()")) ![]() Retrieve a million uuids via the database. Not surprising, considering the database adds round trip delays etc. I've done a wee bit of benchmarking on creating a million UUIDs and even with the function_exists() call added, the pecl function call is in about 8 times faster than getting a UUID from the database. I reckon that if the PECL extension is available, the function should default to using that instead of the database call. If we had another function that ran "SELECT UUID() " on MySQL, and the return value was passed to the INSERT query, I believe we would not have the same problems with statement-based replication. Part of the problem with statement-based replication in the case of this module is that functions like uuid_user() and uuid_nodeapi() call MySQL's UUID() function within an INSERT query. We could create a wrapper function that calls the proper function depending on the database platform being used. In the case of the latter, both MySQL and Postgres have UUID generation functions, but they're different. The former is seeming to be more complicated. I guess there are two ways to approach this - put the burden on the web server, or put the burden on the database server. If you look at some of the other comments on uniqid, other people have implemented UUIDv4 generators that read directly from /dev/urandom, which isn't available on Windows. I think part of the problem is making a cross-platform UUID generator implementation that is collision-proof. In the second case, the code uses mt_rand(), an implementation of the Mersenne Twister, which is not cryptographically secure. cafuego's patch uses the UUID extension if available if not, it generates UUIDv4s using code in comment #65879 on uniqid. If I understand the specification properly, Version 4 UUIDs require that the digits be created by a cryptographically secure random number generator. I'm actually inclined to believe that this UUIDv4 generation function is not collision proof. sorry, meant to reply to your comment before, but didn't.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |