Let's take this example

explain select * from employee,company,location where location.name=
company.name and location.name=employee.name;

addr  opcode         p1    p2    p3    p4             p5  comment

----  -------------  ----  ----  ----  -------------  --  -------------

0     Init           0     46    0                    00  Start at 46

1     OpenRead       0     2     0     2              00  root=2 iDb=0;
employee

2     OpenRead       2     3     0     2              00  root=3 iDb=0;
location

3     OpenRead       1     4     0     2              00  root=4 iDb=0;
company

4     Explain        0     0     0     SCAN TABLE employee  00


5     Rewind         0     44    0                    00

6       Once           0     15    0                    00

7       OpenAutoindex  3     3     0     k(3,nil,nil,nil)  00  nColumn=3;
for location

8       Rewind         2     15    0                    00

9         Column         2     0     2                    00  r[2]=
location.name

10        Column         2     1     3                    00
r[3]=location.addr

11        Rowid          2     4     0                    00  r[4]=rowid

12        MakeRecord     2     3     1                    00
r[1]=mkrec(r[2..4])

13        IdxInsert      3     1     0                    10  key=r[1]

14      Next           2     9     0                    03

15      Explain        0     1     2     SEARCH TABLE location USING
AUTOMATIC COVERING INDEX (name=?)  00

16      Column         0     0     5                    00  r[5]=
employee.name

17      IsNull         5     43    0                    00  if r[5]==NULL
goto 43

18      SeekGE         3     43    5     1              00  key=r[5]

19        IdxGT          3     43    5     1              00  key=r[5]

20        Once           1     29    0                    00

21        OpenAutoindex  4     3     0     k(3,nil,nil,nil)  00  nColumn=3;
for company

22        Rewind         1     29    0                    00

23          Column         1     0     2                    00  r[2]=
company.name

24          Column         1     1     3                    00
r[3]=company.cname

25          Rowid          1     4     0                    00  r[4]=rowid


26          MakeRecord     2     3     1                    00
r[1]=mkrec(r[2..4])

27          IdxInsert      4     1     0                    10  key=r[1]


28        Next           1     23    0                    03

29        Explain        0     2     1     SEARCH TABLE company USING
AUTOMATIC COVERING INDEX (name=?)  00

30        Column         3     0     6                    00  r[6]=
location.name

31        IsNull         6     42    0                    00  if r[6]==NULL
goto 42

32        SeekGE         4     42    6     1              00  key=r[6]

33          IdxGT          4     42    6     1              00  key=r[6]


34          Copy           5     7     0                    00  r[7]=r[5]


35          Column         0     1     8                    00
r[8]=employee.age

36          Column         4     0     9                    00  r[9]=
company.name

37          Column         4     1     10                   00
r[10]=company.cname

38          Copy           6     11    0                    00  r[11]=r[6]


39          Column         3     1     12                   00
r[12]=location.addr

40          ResultRow      7     6     0                    00
output=r[7..12]

41        Next           4     33    0                    00

42      Next           3     19    0                    00

43    Next           0     6     0                    01

44    Close          0     0     0                    00

45    Halt           0     0     0                    00

46    Transaction    0     0     3     0              01

47    TableLock      0     2     0     employee       00  iDb=0 root=2
write=0

48    TableLock      0     3     0     location       00  iDb=0 root=3
write=0

49    TableLock      0     4     0     company        00  iDb=0 root=4
write=0

50    Goto           0     1     0                    00


How's the register for the highlighted opcode allocated and how does the
virtual machine remember this allocation ?

Thanks for your help

On Fri, Sep 19, 2014 at 9:46 AM, Richard Hipp <d...@sqlite.org> wrote:

> On Fri, Sep 19, 2014 at 12:10 AM, Prakash Premkumar <
> prakash.p...@gmail.com>
> wrote:
>
> > Thanks for your reply. I would like to know how the register allocation
> > decision is made and the part of the code which does it . can you please
> > help me find that? Thanks
> >
>
> Which register.
>
> Show me a specific VDBE program and a specific instruction in that program
> and a specific operand on that instruction, and I can point you to the
> place in the code where that register is allocated.
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to