| 1 | -- |
|---|
| 2 | -- Change the paths in the copy commands to get this working! |
|---|
| 3 | -- |
|---|
| 4 | drop table if exists testgist; |
|---|
| 5 | drop table if exists testscan; |
|---|
| 6 | drop table if exists testgist25; |
|---|
| 7 | drop table if exists testscan25; |
|---|
| 8 | create table testgist(id integer, the_box box); |
|---|
| 9 | copy testgist from '/home/cc/cs186/fa07/class/cs186-ee/Hw2/MyStuff/randomboxes' delimiter ';' ; |
|---|
| 10 | create index testgistix on testgist using gist (the_box box_ops); |
|---|
| 11 | |
|---|
| 12 | create table testscan(id integer, the_box box); |
|---|
| 13 | copy testscan from '/home/cc/cs186/fa07/class/cs186-ee/Hw2/MyStuff/randomboxes' delimiter ';' ; |
|---|
| 14 | |
|---|
| 15 | create table testgist25 (id integer, the_box box); |
|---|
| 16 | copy testgist25 from '/home/cc/cs186/fa07/class/cs186-ee/Hw2/MyStuff/randomboxes25' delimiter ';' ; |
|---|
| 17 | create index testgist25ix on testgist25 using gist (the_box box_ops); |
|---|
| 18 | |
|---|
| 19 | create table testscan25(id integer, the_box box); |
|---|
| 20 | copy testscan25 from '/home/cc/cs186/fa07/class/cs186-ee/Hw2/MyStuff/randomboxes25' delimiter ';' ; |
|---|
| 21 | |
|---|
| 22 | -- |
|---|
| 23 | -- Run queries |
|---|
| 24 | -- |
|---|
| 25 | |
|---|
| 26 | -- |
|---|
| 27 | -- Make sure basic near neighbor works on a few tuples |
|---|
| 28 | -- |
|---|
| 29 | -- SeqScan: |
|---|
| 30 | set enable_seqscan to off; |
|---|
| 31 | set enable_bitmapscan to off; |
|---|
| 32 | |
|---|
| 33 | \o runtests.out/1 |
|---|
| 34 | select id, box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') as dist from testscan25 where the_box ~~ '(0.5,0.5,0.5,0.5)' and box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') > 0 order by dist; |
|---|
| 35 | -- index |
|---|
| 36 | \o runtests.out/2 |
|---|
| 37 | select id, box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') as dist from testgist25 where the_box ~~ '(0.5,0.5,0.5,0.5)' and box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') > 0; |
|---|
| 38 | |
|---|
| 39 | -- Bigger tables |
|---|
| 40 | -- |
|---|
| 41 | -- SeqScan: |
|---|
| 42 | \o runtests.out/3 |
|---|
| 43 | select id, box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') as dist from testscan where the_box ~~ '(0.5,0.5,0.5,0.5)' and box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') > 0 order by dist; |
|---|
| 44 | -- index |
|---|
| 45 | \o runtests.out/4 |
|---|
| 46 | select id, box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') as dist from testgist where the_box ~~ '(0.5,0.5,0.5,0.5)' and box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') > 0; |
|---|
| 47 | |
|---|
| 48 | -- |
|---|
| 49 | -- Make sure selections work |
|---|
| 50 | -- |
|---|
| 51 | -- SeqScan: |
|---|
| 52 | \o runtests.out/5 |
|---|
| 53 | select id, box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') as dist from testscan where the_box >> '(0.5,0.5,0.5,0.5)' order by dist; |
|---|
| 54 | -- index |
|---|
| 55 | \o runtests.out/6 |
|---|
| 56 | select id, box_mindistance(the_box, '(0.5,0.5,0.5,0.5)') as dist from testgist where the_box >> '(0.5,0.5,0.5,0.5)'; |
|---|
| 57 | |
|---|
| 58 | -- |
|---|
| 59 | -- Rectangle query |
|---|
| 60 | -- |
|---|
| 61 | -- Check the answer sets are the same |
|---|
| 62 | \o runtests.out/10 |
|---|
| 63 | select id, box_mindistance(the_box, '(0.5,0.7,0.5,0.7)') as dist from testscan where the_box ~~ '(0.5,0.7,0.5,0.7)' except select id, box_mindistance(the_box, '(0.5,0.7,0.5,0.7)') as dist from testscan where the_box ~~ '(0.5,0.7,0.5,0.7)'; |
|---|
| 64 | -- SeqScan: |
|---|
| 65 | \o runtests.out/7 |
|---|
| 66 | select id, box_mindistance(the_box, '(0.5,0.7,0.5,0.7)') as dist from testscan where the_box ~~ '(0.5,0.7,0.5,0.7)' and box_mindistance(the_box, '(0.5,0.7,0.5,0.7)') > 0 order by dist; |
|---|
| 67 | -- index |
|---|
| 68 | \o runtests.out/8 |
|---|
| 69 | select id, box_mindistance(the_box, '(0.5,0.7,0.5,0.7)') as dist from testgist where the_box ~~ '(0.5,0.7,0.5,0.7)' and box_mindistance(the_box, '(0.5,0.7,0.5,0.7)') > 0; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | -- |
|---|
| 73 | -- Drop tables |
|---|
| 74 | -- |
|---|
| 75 | drop table testscan; |
|---|
| 76 | drop table testgist; |
|---|
| 77 | drop table testscan25; |
|---|
| 78 | drop table testgist25; |
|---|