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

docs: add session and environment variables to README #669

Merged
merged 3 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@ We support and actively test against certain third-party clients to ensure compa
- `IFNULL(expr1, expr2)`: If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.
- `NULLIF(expr1, expr2)`: Returns NULL if expr1 = expr2 is true, otherwise returns expr1.

## Configuration

The behaviour of certain parts of go-mysql-server can be configured using either environment variables or session variables.

Session variables are set using the following SQL queries:

```sql
SET <variable name> = <value>
```

### Memory joins


- `INMEMORY_JOINS`: if this environment variable is set it will perform all joins in memory. Default is off.
- `inmemory_joins`: if this session variable is set it will perform all joins in memory. Default is off. This has precedence over `INMEMORY_JOINS`.

### Maximum inner join memory

- `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.
- `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`.

### Debug

- `DEBUG_ANALYZER`: if this environment variable is set, the analyzer will print debug messages. Default is off.

### Index creation threads

- `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.
- `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`.

## Example

`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.
Expand Down
14 changes: 7 additions & 7 deletions sql/plan/innerjoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
)

const (
experimentalInMemoryJoinKey = "EXPERIMENTAL_IN_MEMORY_JOIN"
maxMemoryJoinKey = "MAX_MEMORY_INNER_JOIN"
inMemoryJoinSessionVar = "inmemory_joins"
memoryThresholdSessionVar = "max_memory_joins"
inMemoryJoinKey = "INMEMORY_JOINS"
maxMemoryJoinKey = "MAX_MEMORY_INNER_JOIN"
inMemoryJoinSessionVar = "inmemory_joins"
memoryThresholdSessionVar = "max_memory_joins"
)

var (
Expand All @@ -32,7 +32,7 @@ var (
)

func shouldUseMemoryJoinsByEnv() bool {
v := strings.TrimSpace(strings.ToLower(os.Getenv(experimentalInMemoryJoinKey)))
v := strings.TrimSpace(strings.ToLower(os.Getenv(inMemoryJoinKey)))
return v == "on" || v == "1"
}

Expand All @@ -48,7 +48,7 @@ func loadMemoryThreshold() uint64 {
return defaultMemoryThreshold
}

return n
return n * 1024 // to bytes
}

// InnerJoin is an inner join between two tables.
Expand Down Expand Up @@ -252,7 +252,7 @@ func (i *innerJoinIter) fitsInMemory() bool {
var maxMemory uint64
_, v := i.ctx.Session.Get(memoryThresholdSessionVar)
if n, ok := v.(int64); ok {
maxMemory = uint64(n)
maxMemory = uint64(n) * 1024 // to bytes
} else {
maxMemory = maxMemoryJoin
}
Expand Down
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