This is a discussion on optimize md5_text within the Pgsql Patches forums, part of the PostgreSQL category; --> This patch optimizes the md5_text() function (which is used to implement the md5() SQL-level function). The old code did ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| This patch optimizes the md5_text() function (which is used to implement the md5() SQL-level function). The old code did the following: 1. de-toast the datum 2. convert it to a cstring via textout() 3. get the length of the cstring via strlen() Since we are treating the datum context as a blob of binary data, the latter two steps are unnecessary. Once the data has been detoasted, we can just use it as-is, and derive its length from the varlena metadata. This patch improves some run-of-the-mill md5() computations by just under 10% in my limited tests, and passes the regression tests. I also noticed that md5_text() wasn't checking the return value of md5_hash(); encountering OOM at precisely the right moment could result in returning a random md5 hash. This patch corrects that. A better fix would be to make md5_hash() only return on success (and/or allocate via palloc()), but since it's used in the frontend as well I don't see an easy way to do that. Barring any objections, I'll apply this to HEAD tomorrow. -Neil ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) |
| ||||
| Neil Conway wrote: > This patch optimizes the md5_text() function (which is used to implement > the md5() SQL-level function). Applied. -Neil ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| Thread Tools | |
| Display Modes | |
|
|