mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
8623cb232c
* CLICKHOUSE-4063: less manual html @ index.md * CLICKHOUSE-4063: recommend markdown="1" in README.md * CLICKHOUSE-4003: manually purge custom.css for now * CLICKHOUSE-4064: expand <details> before any print (including to pdf) * CLICKHOUSE-3927: rearrange interfaces/formats.md a bit * CLICKHOUSE-3306: add few http headers * Remove copy-paste introduced in #3392 * Hopefully better chinese fonts #3392 * get rid of tabs @ custom.css * Apply comments and patch from #3384 * Add jdbc.md to ToC and some translation, though it still looks badly incomplete * minor punctuation * Add some backlinks to official website from mirrors that just blindly take markdown sources * Do not make fonts extra light * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's//g' {} * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's/ sql/g' {} * Remove outdated stuff from roadmap.md * Not so light font on front page too * Refactor Chinese formats.md to match recent changes in other languages
78 lines
3.2 KiB
Markdown
78 lines
3.2 KiB
Markdown
<a name="table_functions-remote"></a>
|
||
|
||
# remote
|
||
|
||
Allows you to access remote servers without creating a `Distributed` table.
|
||
|
||
Signatures:
|
||
|
||
``` sql
|
||
remote('addresses_expr', db, table[, 'user'[, 'password']])
|
||
remote('addresses_expr', db.table[, 'user'[, 'password']])
|
||
```
|
||
|
||
`addresses_expr` – An expression that generates addresses of remote servers. This may be just one server address. The server address is `host:port`, or just `host`. The host can be specified as the server name, or as the IPv4 or IPv6 address. An IPv6 address is specified in square brackets. The port is the TCP port on the remote server. If the port is omitted, it uses `tcp_port` from the server's config file (by default, 9000).
|
||
|
||
!!! important
|
||
The port is required for an IPv6 address.
|
||
|
||
Examples:
|
||
|
||
```
|
||
example01-01-1
|
||
example01-01-1:9000
|
||
localhost
|
||
127.0.0.1
|
||
[::]:9000
|
||
[2a02:6b8:0:1111::11]:9000
|
||
```
|
||
|
||
Multiple addresses can be comma-separated. In this case, ClickHouse will use distributed processing, so it will send the query to all specified addresses (like to shards with different data).
|
||
|
||
Example:
|
||
|
||
```
|
||
example01-01-1,example01-02-1
|
||
```
|
||
|
||
Part of the expression can be specified in curly brackets. The previous example can be written as follows:
|
||
|
||
```
|
||
example01-0{1,2}-1
|
||
```
|
||
|
||
Curly brackets can contain a range of numbers separated by two dots (non-negative integers). In this case, the range is expanded to a set of values that generate shard addresses. If the first number starts with zero, the values are formed with the same zero alignment. The previous example can be written as follows:
|
||
|
||
```
|
||
example01-{01..02}-1
|
||
```
|
||
|
||
If you have multiple pairs of curly brackets, it generates the direct product of the corresponding sets.
|
||
|
||
Addresses and parts of addresses in curly brackets can be separated by the pipe symbol (|). In this case, the corresponding sets of addresses are interpreted as replicas, and the query will be sent to the first healthy replica. However, the replicas are iterated in the order currently set in the [load_balancing](../../operations/settings/settings.md#settings-load_balancing) setting.
|
||
|
||
Example:
|
||
|
||
```
|
||
example01-{01..02}-{1|2}
|
||
```
|
||
|
||
This example specifies two shards that each have two replicas.
|
||
|
||
The number of addresses generated is limited by a constant. Right now this is 1000 addresses.
|
||
|
||
Using the `remote` table function is less optimal than creating a `Distributed` table, because in this case, the server connection is re-established for every request. In addition, if host names are set, the names are resolved, and errors are not counted when working with various replicas. When processing a large number of queries, always create the `Distributed` table ahead of time, and don't use the `remote` table function.
|
||
|
||
The `remote` table function can be useful in the following cases:
|
||
|
||
- Accessing a specific server for data comparison, debugging, and testing.
|
||
- Queries between various ClickHouse clusters for research purposes.
|
||
- Infrequent distributed requests that are made manually.
|
||
- Distributed requests where the set of servers is re-defined each time.
|
||
|
||
If the user is not specified, `default` is used.
|
||
If the password is not specified, an empty password is used.
|
||
|
||
|
||
[Original article](https://clickhouse.yandex/docs/en/query_language/table_functions/remote/) <!--hide-->
|