General questions about YDB
What is YDB?
YDB is a fully managed database. DB instances are created through the YDB database management service.
What features does YDB provide?
YDB provides high availability and data security through synchronous replication in three availability zones. YDB also ensures even load distribution across available hardware resources. This means you don’t need to order resources, YDB automatically provisions and releases resources based on the user load.
What consistency model does YDB use?
To read data, YDB uses a model of strict data consistency.
How do I design a primary key?
To design a primary key properly, follow the rules below.
Avoid situations where the main load falls on a single partition of a table. With even load distribution, it’s easier to achieve high overall performance.
This rule implies that you shouldn’t use a monotonically increasing sequence, such as timestamp, as a table’s primary key.
For more information, see .
How do I evenly distribute load across table partitions?
You can use the following techniques to distribute the load evenly across table partitions and increase overall DB performance.
- To avoid using uniformly increasing primary key values, you can:
- Change the order of its components.
- use a hash of the key column values as the primary key.
- Reduce the number of partitions used in a single query.
For more information, see .
Can I use NULL in a key column?
In YDB, all columns, including key ones, may contain a value, but we don’t recommend using as values in key columns.
Per the SQL standard (ISO/IEC 9075), you can’t compare with other values. Therefore, the use of concise SQL statements with simple comparison operators may result in rows containing NULL being skipped during filtering, for example.
Is there an optimal size of a database row?
For more information about limits, see Database limits.
How are secondary indexes used in YDB?
Secondary indexes in YDB are global and can be non-unique.
For more information, see Secondary indexes.
How is paginated output performed?
To organize paginated output, we recommend selecting data sorted by primary key sequentially, limiting the number of rows with the keyword. We do not recommend using the keyword to solve this problem.
For more information, see Paginated output.
How do I efficiently upload large amounts of data to YDB?
To increase upload speed for large amounts of data, follow the recommendations below:
- When creating a table, explicitly specify the required number of partitions or their boundaries. This will help you effectively use system bandwidth as soon as you start uploading data by avoiding unnecessary re-partitioning of the table.
- Don’t insert data in separate transactions for each row. It’s more efficient to insert multiple rows at once (batch inserts). This reduces the overhead on the transaction mechanism itself.
- Avoid writing data sequentially in ascending or descending order of the primary key value to evenly distribute the load across all table partitions.
How do I delete expired data?
To effectively remove expired data, we recommend using .