fts5speed.tcl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. set Q {
  2. {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'enron'"}
  3. {25 "SELECT count(*) FROM t1 WHERE t1 MATCH 'hours'"}
  4. {300 "SELECT count(*) FROM t1 WHERE t1 MATCH 'acid'"}
  5. {100 "SELECT count(*) FROM t1 WHERE t1 MATCH 'loaned OR mobility OR popcore OR sunk'"}
  6. {100 "SELECT count(*) FROM t1 WHERE t1 MATCH 'enron AND myapps'"}
  7. {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'en* AND my*'"}
  8. {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'c:t*'"}
  9. {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'a:t* OR b:t* OR c:t* OR d:t* OR e:t* OR f:t* OR g:t*'"}
  10. {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'a:t*'"}
  11. {2 "SELECT count(*) FROM t1 WHERE t1 MATCH 'c:the'"}
  12. {2 "SELECT count(*) FROM t1 WHERE t1 MATCH 'd:holmes OR e:holmes OR f:holmes OR g:holmes'" }
  13. {2 "SELECT count(*) FROM t1 WHERE t1 MATCH 'd:holmes AND e:holmes AND f:holmes AND g:holmes'" }
  14. {4 "SELECT count(*) FROM t1 WHERE t1 MATCH 'd:holmes NOT e:holmes'" }
  15. }
  16. proc usage {} {
  17. global Q
  18. puts stderr "Usage: $::argv0 DATABASE QUERY"
  19. puts stderr ""
  20. for {set i 1} {$i <= [llength $Q]} {incr i} {
  21. puts stderr " $i. [lindex $Q [expr $i-1]]"
  22. }
  23. puts stderr ""
  24. exit -1
  25. }
  26. set nArg [llength $argv]
  27. if {$nArg!=2 && $nArg!=3} usage
  28. set database [lindex $argv 0]
  29. set iquery [lindex $argv 1]
  30. if {$iquery<1 || $iquery>[llength $Q]} usage
  31. set nRepeat 0
  32. if {$nArg==3} { set nRepeat [lindex $argv 2] }
  33. sqlite3 db $database
  34. catch { load_static_extension db fts5 }
  35. incr iquery -1
  36. set sql [lindex $Q $iquery 1]
  37. if {$nRepeat==0} {
  38. set nRepeat [lindex $Q $iquery 0]
  39. }
  40. puts "sql: $sql"
  41. puts "nRepeat: $nRepeat"
  42. if {[regexp matchinfo $sql]} {
  43. sqlite3_fts5_register_matchinfo db
  44. db eval $sql
  45. } else {
  46. puts "result: [db eval $sql]"
  47. }
  48. for {set i 1} {$i < $nRepeat} {incr i} {
  49. db eval $sql
  50. }