Skip to content

Commit ee833e0

Browse files
authored
querying: Add new section on queries and pipelines (#117)
* querying: Add new section on queries and pipelines * querying: Improve docs
1 parent 0f708aa commit ee833e0

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ To develop using Skytable and maintain your deployment you will want to learn ab
1717
- [**DDL**](blueql/ddl): Data definition with BlueQL
1818
- [**DML**](blueql/dml): Data manipulation with BlueQL
1919
- [**DCL**](blueql/dcl): Data control with BlueQL
20+
- [**Querying**](querying): Introduces different query modes and when to choose a specific query mode
2021
- [**System administration**](system):
2122
- [**Configuration**](system/configuration): Information to help you configure Skytable with custom settings such as custom ports, hosts, TLS, and etc.
2223
- [**User management**](system/user-management): Information on access control, user and other administration features

docs/protocol/specification.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,30 @@ When the client sends a [simple query](#simple-query), the server will respond w
100100
> **Note**: A `<row count>` or `<column cnt>` is the value of the length in question converted to an ASCII string.
101101
102102
[^1]: See the [discussion here](https://github.com/skytable/skytable/issues/332)
103+
104+
### Pipeline
105+
106+
A pipeline is a type of query that is used to send multiple queries to the server at once, and the server will return the responses in the same order. There is nothing special about the structure of pipelines. Consider [reviewing this section on pipelines](/querying/#pipelines).
107+
108+
**⚠️ Illegal packet error escape**: If the client incorrectly encodes a pipeline (even though some of the first queries may be encoded correctly), the server will execute the correctly encoded queries and then instead of sending any further responses it will respond with a `0xFF` byte. This is equivalent to [*Query Error 25*](errors#query-errors).
109+
110+
#### Pipeline query
111+
112+
The client is expected to encode the query in the following way:
113+
114+
```
115+
P<full packet size>\n
116+
<query size>\n<param payload size>\n<query><param>
117+
<query size>\n<param payload size>\n<query><param>
118+
...
119+
```
120+
121+
#### Pipeline response
122+
123+
The server will return multiple responses:
124+
125+
```
126+
<response 1>
127+
<response 2>
128+
...
129+
```

docs/querying.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
id: querying
3+
title: Querying
4+
---
5+
6+
## Simple queries
7+
8+
A simple query is a type of query in which the client sends one query to the server and the server returns an appropriate response (or an error). There are no explicit guarantees provided about the execution of a simple query, other than what was described earlier in the [section on BlueQL](blueql). DDL and DCL queries are guaranteed to be ACID. DML queries are guaranteed to be atomic but have delayed durability.
9+
10+
**When should you use simple queries?** The majority of use-cases will involve running simple queries.
11+
12+
> **Note**: The execution guarantees for queries only apply when the are executed as simple queries.
13+
14+
:::info
15+
Fully ACID transactions are being worked on and will be available for use soon.
16+
:::
17+
18+
## Pipelines
19+
20+
A pipeline is a method of sending multiple queries to the server at once, instead of being sent individually. The server keeps the queries in a queue and then executes them one-by-one in order, writing each response to the connection. **Pipelines do not provide any concurrency and execution guarantees** and should not be used in place of ACID transactions. It is merely a convenience provided to reduce round-trip-times (RTTs) associated with multiple requests to the server.
21+
22+
**When should you use pipelines?** Pipelines are to be used when you have to run queries that can run *independently* of one another. For example, if you're "banning some users" you could just put all your `UPDATE` queries in a pipeline and send them to the server. The server will serially execute all the `UPDATE`s independently of one another. If someone `DELETE`s their "account" (i.e the row is gone) that's still fine because you were banning them anyway.
23+
24+
> **Note**: To use pipelines, both your client and server should support pipelines. Pipelines were re-added in 0.8.2 so any client that supports pipelines should be paired with server versions >= 0.8.2

sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
id: 'blueql/index'
2020
}
2121
},
22+
"querying",
2223
{
2324
type: 'category',
2425
label: 'System Administration',

0 commit comments

Comments
 (0)