Skip to content

Commit 79939c3

Browse files
committed
Describe auto-incrementing primary keys
1 parent 77cb9ee commit 79939c3

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

docs/developers/applications/defining-schemas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ The field directives can be used for information about each attribute in table t
165165

166166
#### `@primaryKey`
167167

168-
The `@primaryKey` directive specifies that an attribute is the primary key for a table. These must be unique and when records are created, this will be auto-generated with a UUID if no primary key is provided.
168+
The `@primaryKey` directive specifies that an attribute is the primary key for a table. These must be unique and when records are created, this will be auto-generated if no primary key is provided. When a primary key is auto-generated, it will be a UUID (as a string) if the primary key type is `String` or `ID`. If the primary key type is `Int`, `Long`, or `Any`, then the primary key will be an auto-incremented number. Using numeric primary keys is more efficient than using UUIDs. Note that if the type is `Int`, the primary key will be limited to 32-bit, which can be limiting and problematic for large tables. It is recommended that if you will be relying on auto-generated keys, that you use a primary key type of `Long` or `Any` (the latter will allow you to also use strings as primary keys).
169169

170170
#### `@indexed`
171171

docs/developers/operations-api/nosql-operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Insert
44

5-
Adds one or more rows of data to a database table. Primary keys of the inserted JSON record may be supplied on insert. If a primary key is not provided, then a GUID will be generated for each record.
5+
Adds one or more rows of data to a database table. Primary keys of the inserted JSON record may be supplied on insert. If a primary key is not provided, then a GUID or incremented number (depending on type) will be generated for each record.
66

77
* operation _(required)_ - must always be `insert`
88
* database _(optional)_ - database where the table you are inserting records into lives. The default is `data`

docs/technical-details/release-notes/4.tucker/4.4.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ On startup, HarperDB will now print out an informative status of all running ser
4242

4343
Resource methods can now return a `Response` object (or an object with `headers` and `status`) to allow for more control over the response.
4444

45+
### Auto-incrementing Primary Keys
46+
47+
Primary keys can now be auto-incrementing, allowing for automatic generation of numeric primary keys on insert/creation. Primary keys defined with `ID` or `String` will continue to use GUIDs for auto-assigned primary keys, which occurs on insert or creation if the primary key is not provided. However, for keys that are defined as `Any`, `Int`, or `Long`, the primary key will be assigned using auto-incrementation. This is significantly more efficient than GUIDs since the key only requires 8 bytes of storage instead of 31 bytes, and doesn't require random number generation.
48+
4549
#### Developer/Production Mode for Configuration
4650

4751
When using interactive installation (when configuration is not provided through arguments or env vars), HarperDB now provides an option for developer or production mode with a set of default configuration for each mode better suited for developer or production environments.

0 commit comments

Comments
 (0)