Closed tishyakhanna97 closed 2 years ago
Test query:
create index en_eid_idx on enroll(eid) using btree
select eid,sectionid from enroll where eid=14
create index dept_did_idx on dept(did) using hash
select did,dname from dept where did=10
For both queries, the index was used after it was created
Non eq search using index
Create Index using Hash on Students.sid Create Index using Hash on Students.sname
create index stu_id on student(sid) using hash
, create index stu_name on student(sname) using hash
SQL> select sid, sname from student where sid = 5
,
index on sid used
sid sname
----------
5 bob
transaction 2 committed
SQL> select sid, sname from student where sname = 'bob'
,
index on sname used
sid sname
----------
5 bob
transaction 2 committed
SQL> select sid, sname from student where sid > 5
,
index on sid used
sid sname
----------
transaction 2 committed
SQL> select sid, sname from student where sname > 'bob'
,
index on sname used
sid sname
----------
transaction 2 committed
Create Index using Btree on Students.sid Create Index using Btree on Students.sname
create index stu_id on student(sid) using btree
create index stu_name on student(sname) using btree
No issues - expected behavior (except for >= and <=)
No issues - expected behavior
Create index using Hash on students.sid and Btree on students.sname Create index using Hash on students.sname and Btree on students.sid
create index stu_sid_idx on student(sid) using btree
&& create index stu_name_idx on student(sname) using hash
create index stu_sid_idx on student(sid) using hash
&& create index stu_name_idx on student(sname) using btree
No issues - expected behavior `select sid, sname from student where sid = 5 and sname = 'bob' (btree on id, hash on sname)
index on sname used
sid sname
----------
5 bob
transaction 2 committed
`select sid, sname from student where sid = 5 and sname = 'bob' (hash on id, btree on sname)
index on sname used
sid sname
----------
5 bob
transaction 2 committed
`#### Non Equality Search No issues - expected behavior
Create index on non existent table: Unexpected behavior: Index is created on uninitialized table. index is also usable. Indexes can also be created if there is no such table
creating new database
transaction 1 committed
BTree index stu_sid_idx created on STUDENT(sid).
Table STUDENT created.
Create index after inserting values:
Unexpected behavior: no output
Input:
select sname from student where sname = 'bob'
Output:
index on sname used
sname
------
transaction 2 committed
Unexpected behavior:
Input:
select sid, sname from student where sname >= 'bob'
Output:
index on sname used
sid sname
----------
5 bob
transaction 2 committed
Input: (string without quotes)
select sid from student where sname = bob
Output:
(all sids)
Input:
select sname from student where sname = 'bob'
Output:
index on sname used
sname
------
transaction 2 committed
Moved errors to other issues. Otherwise indexes seem to be alright
Lab 2
Check if non equality predicates work fine: