On Wed, 2007-07-18 at 16:03 +0530, B V, Phanisekhar wrote: > Assume I have an albumtable: > > create table albumtable (albumid INTEGER PRIMARY KEY, album BLOB); > > > > Now I do a query to return the entire albums in the albumtable table in > alphabetical order: > > > > The instructions for the above query are given below: > > > > explain select album from albumtable order by album; > > > > addr opcode p1 p2 p3 > > ---- -------------- ---------- ---------- > ----------------------------- > > 0 OpenEphemeral 1 3 keyinfo(1,BINARY) > > 1 Goto 0 26 > > 2 Integer 0 0 > > 3 OpenRead 0 2 > > 4 SetNumColumns 0 2 > > 5 Rewind 0 14 > > 6 Column 0 1 > > 7 MakeRecord 1 0 > > 8 Column 0 1 > > 9 Sequence 1 0 > > 10 Pull 2 0 > > 11 MakeRecord 3 0 > > 12 IdxInsert 1 0 > > 13 Next 0 6 > > 14 Close 0 0 > > 15 OpenPseudo 2 0 > > 16 SetNumColumns 2 1 > > 17 Sort 1 24 > > 18 Integer 1 0 > > 19 Column 1 2 > > 20 Insert 2 0 > > 21 Column 2 0 > > 22 Callback 1 0 > > 23 Next 1 18 > > 24 Close 2 0 > > 25 Halt 0 0 > > 26 Transaction 0 0 > > 27 VerifyCookie 0 1 > > 28 Goto 0 2 > > 29 Noop 0 0 > > > > I would like to know which portion of the above code does the sorting of > the blobs "album". > > Basically would like to know where exactly the comparison "album A > > album B" is done.
Instructions 6-13 are a loop inserting rows into a temporary b-tree structure. The value of the "album" column is used as the key for this table. Instructions 17-23 iterate through this table, pulling records out in sorted order. So the comparison is done in instruction 12. Dan. > > > > Regards, > > Phanisekhar > > > > > > > > > ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------