Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 3e54829

Browse files
authored
Merge pull request #669 from erizocosmico/docs/env-vars
docs: add session and environment variables to README
2 parents c9ee09f + 0a85186 commit 3e54829

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,36 @@ We support and actively test against certain third-party clients to ensure compa
9595
- `IFNULL(expr1, expr2)`: If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.
9696
- `NULLIF(expr1, expr2)`: Returns NULL if expr1 = expr2 is true, otherwise returns expr1.
9797

98+
## Configuration
99+
100+
The behaviour of certain parts of go-mysql-server can be configured using either environment variables or session variables.
101+
102+
Session variables are set using the following SQL queries:
103+
104+
```sql
105+
SET <variable name> = <value>
106+
```
107+
108+
### Memory joins
109+
110+
111+
- `INMEMORY_JOINS`: if this environment variable is set it will perform all joins in memory. Default is off.
112+
- `inmemory_joins`: if this session variable is set it will perform all joins in memory. Default is off. This has precedence over `INMEMORY_JOINS`.
113+
114+
### Maximum inner join memory
115+
116+
- `MAX_MEMORY_INNER_JOIN`: this environment variable controls in megabytes the maximum number of memory that can be consumed by go-mysql-server before switching to multipass mode in inner joins. Default is the 20% of all available physical memory.
117+
- `max_memory_joins`: this session variable controls in megabytes the maximum number of memory that can be consumed by go-mysql-server before switching to multipass mode in inner joins. Default is the 20% of all available physical memory. This has precedence over `MAX_MEMORY_INNER_JOIN`.
118+
119+
### Debug
120+
121+
- `DEBUG_ANALYZER`: if this environment variable is set, the analyzer will print debug messages. Default is off.
122+
123+
### Index creation threads
124+
125+
- `PILOSA_INDEX_THREADS`: this environment variable sets the number of threads used in index creation. Default is the number of cores available in the machine.
126+
- `pilosa_index_threads`: this session variable sets the number of threads used in index creation. Default is the number of cores available in the machine. This has precedence over `PILOSA_INDEX_THREADS`.
127+
98128
## Example
99129

100130
`go-mysql-server` contains a SQL engine and server implementation. So, if you want to start a server, first instantiate the engine and pass your `sql.Database` implementation.

sql/plan/innerjoin.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
)
1616

1717
const (
18-
experimentalInMemoryJoinKey = "EXPERIMENTAL_IN_MEMORY_JOIN"
19-
maxMemoryJoinKey = "MAX_MEMORY_INNER_JOIN"
20-
inMemoryJoinSessionVar = "inmemory_joins"
21-
memoryThresholdSessionVar = "max_memory_joins"
18+
inMemoryJoinKey = "INMEMORY_JOINS"
19+
maxMemoryJoinKey = "MAX_MEMORY_INNER_JOIN"
20+
inMemoryJoinSessionVar = "inmemory_joins"
21+
memoryThresholdSessionVar = "max_memory_joins"
2222
)
2323

2424
var (
@@ -32,7 +32,7 @@ var (
3232
)
3333

3434
func shouldUseMemoryJoinsByEnv() bool {
35-
v := strings.TrimSpace(strings.ToLower(os.Getenv(experimentalInMemoryJoinKey)))
35+
v := strings.TrimSpace(strings.ToLower(os.Getenv(inMemoryJoinKey)))
3636
return v == "on" || v == "1"
3737
}
3838

@@ -48,7 +48,7 @@ func loadMemoryThreshold() uint64 {
4848
return defaultMemoryThreshold
4949
}
5050

51-
return n
51+
return n * 1024 // to bytes
5252
}
5353

5454
// InnerJoin is an inner join between two tables.
@@ -252,7 +252,7 @@ func (i *innerJoinIter) fitsInMemory() bool {
252252
var maxMemory uint64
253253
_, v := i.ctx.Session.Get(memoryThresholdSessionVar)
254254
if n, ok := v.(int64); ok {
255-
maxMemory = uint64(n)
255+
maxMemory = uint64(n) * 1024 // to bytes
256256
} else {
257257
maxMemory = maxMemoryJoin
258258
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy