Skip to content

Commit 79c943f

Browse files
committed
Add a bit more documentation, and add the Optimize::DEFAULT constant
1 parent 9650475 commit 79c943f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/sqlite3/constants.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,27 @@ module Status
172172
end
173173

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

179-
# Run ANALYZE on tables that might benefit.
179+
# Run ANALYZE on tables that might benefit. On by default.
180180
ANALYZE_TABLES = 0x00002
181181

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

185186
# Check the size of all tables, not just tables that have not been recently used, to see if
186-
# any have grown and shrunk significantly and hence might benefit from being re-analyzed.
187+
# any have grown and shrunk significantly and hence might benefit from being re-analyzed. Off
188+
# by default.
187189
CHECK_ALL_TABLES = 0x10000
190+
191+
# Useful for adding a bit to the default behavior, for example
192+
#
193+
# db.optimize(Optimize::DEFAULT | Optimize::CHECK_ALL_TABLES)
194+
#
195+
DEFAULT = ANALYZE_TABLES | LIMIT_ANALYZE
188196
end
189197
end
190198
end

lib/sqlite3/pragmas.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ def mmap_size=(size)
342342
#
343343
# To customize the optimization options, pass +bitmask+ with a combination
344344
# of the Constants::Optimize masks.
345+
#
346+
# See https://www.sqlite.org/pragma.html#pragma_optimize for more information.
345347
def optimize(bitmask = nil)
346348
if bitmask
347349
set_int_pragma "optimize", bitmask

0 commit comments

Comments
 (0)