On Mon, 08 Nov 2010 12:24:22 -0500, George <[email protected]> wrote:
> Hi there. I'm wondering what the best way to represent a 16 byte UUID in > sqlite might be (I didn't see any specific data type for UUIDs in the > documentation, but forgive me if there is). > > I could just stringify or blob it, but I might have to index a large > number > of items by this identifier (thousands) , so speed is a consideration > more > than space would be. BLOBs are always compared using memcmp(). Hopefully that is an intrinsic in your compiler. TEXT strings may be compared case-sensitively, case-insensitively, or with a user-defined collating function. Note that you can bind and insert any arbitrary bytes as a TEXT value; SQLite simply assumes you are inserting valid UTF-8/UTF-16 (depending on database encoding). I therefore presume (but do not know for certain) that in the unlikely event you somehow have something faster than memcmp(), you could stuff your 16-byte UUIDs in as TEXT and apply your user collation. Yes, that would be a very ugly hack; and there may (or may not) be additional user-function overhead which would overwhelm the speed advantage of a hypothetical faster-than-memcmp() function. Those are the only two SQLite3 datatypes capable of holding a 16-byte value. Samuel Adam <[email protected]> 763 Montgomery Road Hillsborough, NJ 08844-1304 United States http://certifound.com/ _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

