Re: [sqlite] sorting of blobs

2007-07-18 Thread John Stanton

Well done, you have answered the man's question.

Joe Wilson wrote:

--- John Stanton <[EMAIL PROTECTED]> wrote:


Try looking at the SORT opcode.  You can track it through the Sqlite source.



OP_Sort doesn't sort any longer. 
It just does a rewind on the cursor.


/* Opcode: Sort P1 P2 *
**
** This opcode does exactly the same thing as OP_Rewind except that
** it increments an undocumented global variable used for testing.
**
** Sorting is accomplished by writing records into a sorting index,
** then rewinding that index and playing it back from beginning to
** end.  We use the OP_Sort opcode instead of OP_Rewind to do the
** rewinding so that the global variable will be incremented and
** regression tests can determine whether or not the optimizer is
** correctly optimizing out sorts.
*/



  

Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 




-
To unsubscribe, send email to [EMAIL PROTECTED]
-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] sorting of blobs

2007-07-18 Thread Joe Wilson
--- John Stanton <[EMAIL PROTECTED]> wrote:
> Try looking at the SORT opcode.  You can track it through the Sqlite source.

OP_Sort doesn't sort any longer. 
It just does a rewind on the cursor.

/* Opcode: Sort P1 P2 *
**
** This opcode does exactly the same thing as OP_Rewind except that
** it increments an undocumented global variable used for testing.
**
** Sorting is accomplished by writing records into a sorting index,
** then rewinding that index and playing it back from beginning to
** end.  We use the OP_Sort opcode instead of OP_Rewind to do the
** rewinding so that the global variable will be incremented and
** regression tests can determine whether or not the optimizer is
** correctly optimizing out sorts.
*/



  

Shape Yahoo! in your own image.  Join our Network Research Panel today!   
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] sorting of blobs

2007-07-18 Thread John Stanton

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 Goto0   26

2 Integer 0   0

3 OpenRead0   2

4 SetNumColumns   0   2

5 Rewind  0   14

6 Column  0   1

7 MakeRecord  1   0

8 Column  0   1

9 Sequence1   0

10Pull2   0

11MakeRecord  3   0

12IdxInsert   1   0

13Next0   6

14Close   0   0

15OpenPseudo  2   0

16SetNumColumns   2   1

17Sort1   24

18Integer 1   0

19Column  1   2

20Insert  2   0

21Column  2   0

22Callback1   0

23Next1   18

24Close   2   0

25Halt0   0

26Transaction 0   0

27VerifyCookie0   1

28Goto0   2

29Noop0   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.

 


Regards,

Phanisekhar


Try looking at the SORT opcode.  You can track it through the Sqlite source.

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] sorting of blobs

2007-07-18 Thread Dan Kennedy
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 Goto0   26
> 
> 2 Integer 0   0
> 
> 3 OpenRead0   2
> 
> 4 SetNumColumns   0   2
> 
> 5 Rewind  0   14
> 
> 6 Column  0   1
> 
> 7 MakeRecord  1   0
> 
> 8 Column  0   1
> 
> 9 Sequence1   0
> 
> 10Pull2   0
> 
> 11MakeRecord  3   0
> 
> 12IdxInsert   1   0
> 
> 13Next0   6
> 
> 14Close   0   0
> 
> 15OpenPseudo  2   0
> 
> 16SetNumColumns   2   1
> 
> 17Sort1   24
> 
> 18Integer 1   0
> 
> 19Column  1   2
> 
> 20Insert  2   0
> 
> 21Column  2   0
> 
> 22Callback1   0
> 
> 23Next1   18
> 
> 24Close   2   0
> 
> 25Halt0   0
> 
> 26Transaction 0   0
> 
> 27VerifyCookie0   1
> 
> 28Goto0   2
> 
> 29Noop0   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]
-



[sqlite] sorting of blobs

2007-07-18 Thread B V, Phanisekhar
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 Goto0   26

2 Integer 0   0

3 OpenRead0   2

4 SetNumColumns   0   2

5 Rewind  0   14

6 Column  0   1

7 MakeRecord  1   0

8 Column  0   1

9 Sequence1   0

10Pull2   0

11MakeRecord  3   0

12IdxInsert   1   0

13Next0   6

14Close   0   0

15OpenPseudo  2   0

16SetNumColumns   2   1

17Sort1   24

18Integer 1   0

19Column  1   2

20Insert  2   0

21Column  2   0

22Callback1   0

23Next1   18

24Close   2   0

25Halt0   0

26Transaction 0   0

27VerifyCookie0   1

28Goto0   2

29Noop0   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.

 

Regards,

Phanisekhar