Skip to content

Commit

Permalink
Add a bit more documentation, and add the Optimize::DEFAULT constant
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Oct 31, 2024
1 parent 9650475 commit 79c943f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/sqlite3/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,27 @@ module Status
end

module Optimize
# Debugging mode. Do not actually perform any optimizations but instead return one line of text
# for each optimization that would have been done.
# Debugging mode. Do not actually perform any optimizations but instead return one line of
# text for each optimization that would have been done. Off by default.
DEBUG = 0x00001

# Run ANALYZE on tables that might benefit.
# Run ANALYZE on tables that might benefit. On by default.
ANALYZE_TABLES = 0x00002

# When running ANALYZE, set a temporary PRAGMA analysis_limit to prevent excess run-time.
# When running ANALYZE, set a temporary PRAGMA analysis_limit to prevent excess run-time. On
# by default.
LIMIT_ANALYZE = 0x00010

# Check the size of all tables, not just tables that have not been recently used, to see if
# any have grown and shrunk significantly and hence might benefit from being re-analyzed.
# any have grown and shrunk significantly and hence might benefit from being re-analyzed. Off
# by default.
CHECK_ALL_TABLES = 0x10000

# Useful for adding a bit to the default behavior, for example
#
# db.optimize(Optimize::DEFAULT | Optimize::CHECK_ALL_TABLES)
#
DEFAULT = ANALYZE_TABLES | LIMIT_ANALYZE
end
end
end
2 changes: 2 additions & 0 deletions lib/sqlite3/pragmas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ def mmap_size=(size)
#
# To customize the optimization options, pass +bitmask+ with a combination
# of the Constants::Optimize masks.
#
# See https://www.sqlite.org/pragma.html#pragma_optimize for more information.
def optimize(bitmask = nil)
if bitmask
set_int_pragma "optimize", bitmask
Expand Down

0 comments on commit 79c943f

Please sign in to comment.