About sql minifier
Shrink SQL by removing comments and extra whitespace while keeping quoted text exactly as it is.
When to minify
For SQL embedded in code or sent over a network. Keep the formatted version for editing and review.
A worked example
A formatted query with comments and line breaks becomes a single line such as SELECT id,name FROM users WHERE active=1. Text in quotes keeps its spaces and comments, and strings with -- inside are not mistaken for comments.
When to minify
- Embedding a query in a log line or a configuration value.
- Comparing queries without noise from whitespace.
- Sending SQL in a URL or a single-line field.
Do not minify what you maintain
Keep the formatted query in your source files. Minified SQL is for storing or transmitting, and is hard to debug.
Comments
Remove comments only if they are not needed. Some systems use hint comments, such as /*+ INDEX(...) */, that change how a query is run.
