Skip to content

Commit 4adeeea

Browse files
author
Carl Sverre
committed
readme tweaks for clarity
noci
1 parent d7e7128 commit 4adeeea

File tree

1 file changed

+57
-32
lines changed

1 file changed

+57
-32
lines changed

README.md

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This package is currently in a pre-release beta, please use with caution and ope
1111
- [Issues connecting to SingleStore Managed Service](#issues-connecting-to-singlestore-managed-service)
1212
- [PHP Versions before 8.1](#php-versions-before-81)
1313
- [Migrations](#migrations)
14+
- [Universal Storage Tables (Columnstore)](#universal-storage-tables-columnstore)
1415
- [Rowstore Tables](#rowstore-tables)
1516
- [Reference Tables](#reference-tables)
1617
- [Global Temporary Tables](#global-temporary-tables)
@@ -21,6 +22,7 @@ This package is currently in a pre-release beta, please use with caution and ope
2122
- [Unique Keys](#unique-keys)
2223
- [Series Timestamps](#series-timestamps)
2324
- [Computed Columns](#computed-columns)
25+
- [Increment Columns without Primary Key](#increment-columns-without-primary-key)
2426
- [Testing](#testing)
2527
- [License](#license)
2628
- [Resources](#resources)
@@ -85,7 +87,7 @@ In case you want to store failed jobs in SingleStore, then make sure you also se
8587

8688
If you are encountering issues connecting to the SingleStore Managed Service, it may be due to your environment not being able to verify the SSL certificate used to secure connections. You can fix this by downloading and manually specifying the SingleStore certificate file.
8789

88-
* [Download the file here](https://portal.singlestore.com/static/ca/singlestore_bundle.pem)
90+
* [Download the file here][singlestore-pem]
8991
* In the Laravel SingleStore connection configuration, point the variable `PDO::MYSQL_ATTR_SSL_CA` at `singlestore_bundle.pem`:
9092

9193
```php
@@ -105,18 +107,30 @@ get a string like `"5423"` in PHP.
105107

106108
This is a historic and known bug:
107109

108-
- [https://stackoverflow.com/a/58830039/3275796](https://stackoverflow.com/a/58830039/3275796)
109-
- [https://github.com/php/php-src/blob/7b34db0659dda933b1146a0ff249f25acca1d669/UPGRADING#L130-L134](https://github.com/php/php-src/blob/7b34db0659dda933b1146a0ff249f25acca1d669/UPGRADING#L130-L134)
110+
- https://stackoverflow.com/a/58830039/3275796
111+
- https://github.com/php/php-src/blob/7b34db0659dda933b1146a0ff249f25acca1d669/UPGRADING#L130-L134
110112

111-
The best method to solve this is to upgrade to PHP 8.1 or higher. If that's not possible, [Eloquent's attribute casting](https://laravel.com/docs/9.x/eloquent-mutators#attribute-casting) is the next best solution.
113+
The best method to solve this is to upgrade to PHP 8.1 or higher. If that's not possible, [Eloquent's attribute casting] is the next best solution.
112114

113115
## Migrations
114116

115-
This driver provides many SingleStore specific methods for creating or modifying tables. They are listed below. For more information see the [Create Table](https://docs.singlestore.com/managed-service/en/reference/sql-reference/data-definition-language-ddl/create-table.html) docs on SingleStore.
117+
This driver provides many SingleStore specific methods for creating or modifying tables. They are listed below. For more information see the [create table] docs on SingleStore.
118+
119+
### Universal Storage Tables (Columnstore)
120+
121+
By default, tables created by this driver will use [SingleStoreDB Universal Storage][columnstore]. Universal Storage leverages both column and row oriented data structures to automatically optimize storage for transactional and analytical workloads. In general, you should use this table type for all tables unless you profile your workload and determine that another table type is better.
122+
123+
To create a table, you can simply use `Schema::create`:
124+
125+
```php
126+
Schema::create('table', function (Blueprint $table) {
127+
// ... column definitions, indexes, table options
128+
});
129+
```
116130

117131
### Rowstore Tables
118132

119-
To create a rowstore table, use the `rowstore` method.
133+
To create a [rowstore] table, use the `rowstore` method. Rowstore tables are optimized for low-latency transactional workloads with high concurrency at the expense of memory. In general, we recommend using Universal Storage (see above) and benchmarking your workload before using a rowstore table.
120134

121135
```php
122136
Schema::create('table', function (Blueprint $table) {
@@ -128,7 +142,7 @@ Schema::create('table', function (Blueprint $table) {
128142

129143
### Reference Tables
130144

131-
To create a reference table, you may use the `reference` method.
145+
To create a [reference table], you may use the `reference` method. Reference tables are fully replicated to every node in the cluster. This means that if you store 1000 rows in a reference table, those 1000 rows will be copied many times. Because of this you should only store small amounts of data in reference tables, and only when you need to reference that data via joins against non-collocated data in other tables. Inserts and updates to reference tables will also run slower due to the high replication overhead.
132146

133147
```php
134148
Schema::create('table', function (Blueprint $table) {
@@ -140,7 +154,7 @@ Schema::create('table', function (Blueprint $table) {
140154

141155
### Global Temporary Tables
142156

143-
To create a [global temporary table](https://docs.singlestore.com/managed-service/en/reference/sql-reference/data-definition-language-ddl/create-table.html), you may use the `global` method on the table.
157+
To create a [global temporary table], you may use the `global` method on the table.
144158

145159
```php
146160
Schema::create('table', function (Blueprint $table) {
@@ -164,7 +178,7 @@ $table->temporary($global = true);
164178

165179
### Sparse Columns
166180

167-
You can mark particular columns as [sparse](https://docs.singlestore.com/managed-service/en/reference/sql-reference/data-definition-language-ddl/create-table.html) fluently by appending `sparse` to the column's definition.
181+
You can mark particular columns as [sparse] fluently by appending `sparse` to the column's definition. This only applies to Rowstore tables.
168182

169183
```php
170184
Schema::create('table', function (Blueprint $table) {
@@ -176,7 +190,7 @@ Schema::create('table', function (Blueprint $table) {
176190

177191
### Sparse Tables
178192

179-
You can mark particular entire tables as [sparse](https://docs.singlestore.com/managed-service/en/reference/sql-reference/data-definition-language-ddl/create-table.html) fluently by appending `sparse` to the column's definition.
193+
You can mark particular entire tables as [sparse] fluently by appending `sparse` to the column's definition. This only applies to Rowstore tables.
180194

181195
```php
182196
Schema::create('table', function (Blueprint $table) {
@@ -190,7 +204,7 @@ Schema::create('table', function (Blueprint $table) {
190204

191205
### Shard Keys
192206

193-
You can add a [shard key](https://docs.singlestore.com/managed-service/en/developer-resources/porting-tables-to-singlestoredb-cloud/shard-keys.html) to your tables using the standalone `shardKey` method, or fluently by appending `shardKey` to the column definition.
207+
You can add a [shard key] to your tables using the standalone `shardKey` method, or fluently by appending `shardKey` to the column definition.
194208

195209
```php
196210
Schema::create('table', function (Blueprint $table) {
@@ -213,7 +227,7 @@ Schema::create('table', function (Blueprint $table) {
213227

214228
### Sort Keys
215229

216-
You can add a [sort key](https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/procedures-for-physical-database-schema-design/creating-a-columnstore-table.html) to your tables using the standalone `sortKey` method, or fluently by appending `sortKey` to the column definition.
230+
You can add a [sort key] to your tables using the standalone `sortKey` method, or fluently by appending `sortKey` to the column definition.
217231

218232
```php
219233
Schema::create('table', function (Blueprint $table) {
@@ -234,7 +248,7 @@ Schema::create('table', function (Blueprint $table) {
234248
});
235249
```
236250

237-
Sort keys by default works only for `asc` sort queries. If you would like to create a sort key with `desc` order, you can set the key direction.
251+
Sort keys sort in ascending order by default. If you would like to create a sort key which sorts descending you can set the key direction to `desc`.
238252

239253
```php
240254
Schema::create('table', function (Blueprint $table) {
@@ -259,6 +273,20 @@ Schema::create('table', function (Blueprint $table) {
259273
});
260274
```
261275

276+
Sometimes you may want to tune [columnstore][columnstore-tuning] per table. You can do it by appending `with` fluently to the `sortKey` definition.
277+
278+
```php
279+
Schema::create('table', function (Blueprint $table) {
280+
$table->string('name');
281+
282+
$table->sortKey('name')->with(['columnstore_segment_rows' => 100000]);
283+
});
284+
285+
Schema::create('table', function (Blueprint $table) {
286+
$table->string('name')->sortKey()->with(['columnstore_segment_rows' => 100000]);
287+
});
288+
```
289+
262290
### Unique Keys
263291

264292
You can add an `unique key` to your tables using the standalone `unique` method, or fluently by appending `unique` to the column definition.
@@ -281,22 +309,6 @@ Schema::create('table', function (Blueprint $table) {
281309
});
282310
```
283311

284-
### Sort Keys - Columnstore variables
285-
286-
Sometimes you may want to customize your [columstore variables](https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/procedures-for-physical-database-schema-design/configuring-the-columnstore-to-work-effectively.html) individually per table. You can do it by appending `with` fluently to the `sortKey` definition.
287-
288-
```php
289-
Schema::create('table', function (Blueprint $table) {
290-
$table->string('name');
291-
292-
$table->sortKey('name')->with(['columnstore_segment_rows' => 100000]);
293-
});
294-
295-
Schema::create('table', function (Blueprint $table) {
296-
$table->string('name')->sortKey()->with(['columnstore_segment_rows' => 100000]);
297-
});
298-
```
299-
300312
### Series Timestamps
301313
To denote a column as a series timestamp, use the `seriesTimestamp` column modifier.
302314

@@ -311,7 +323,7 @@ Schema::create('table', function (Blueprint $table) {
311323

312324
### Computed Columns
313325

314-
SingleStore does not support virtual computed columns. You must use Laravel's [`storedAs`](https://laravel.com/docs/9.x/migrations#column-modifiers) method to create a [persisted computed column](https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/procedures-for-physical-database-schema-design/using-persistent-computed-columns.html).
326+
SingleStore does not support virtual computed columns. You must use Laravel's [`storedAs`] method to create a [persisted computed column].
315327

316328
```php
317329
Schema::create('test', function (Blueprint $table) {
@@ -323,8 +335,7 @@ Schema::create('test', function (Blueprint $table) {
323335

324336
### Increment Columns without Primary Key
325337

326-
Sometimes you may want to set a custom primary key. However if your table has an int `increment` column,
327-
Laravel, by default, always sets this column as the primary key. Even if you manually set another one. This behavior can be disabled using the `withoutPrimaryKey` method.
338+
Sometimes you may want to set a custom primary key. However if your table has an int `increment` column, Laravel, by default, always sets this column as the primary key. Even if you manually set another one. This behavior can be disabled using the `withoutPrimaryKey` method.
328339

329340
```php
330341
Schema::create('test', function (Blueprint $table) {
@@ -379,3 +390,17 @@ RESPECT TO THIS BETA SOFTWARE CONNECTOR (INCLUDING TOOLS AND UTILITIES).
379390
APPLICABLE OPEN SOURCE LICENSE: Apache 2.0
380391

381392
IF YOU OR YOUR COMPANY DO NOT AGREE TO THESE TERMS AND CONDITIONS, DO NOT CHECK THE ACCEPTANCE BOX, AND DO NOT DOWNLOAD, ACCESS, COPY, INSTALL OR USE THE SOFTWARE OR THE SERVICES.
393+
394+
[reference table]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/concepts-of-physical-database-schema-design/other-schema-concepts.html#reference-tables-654455
395+
[global temporary table]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/concepts-of-physical-database-schema-design/other-schema-concepts.html#global-temporary-tables
396+
[columnstore]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/concepts-of-physical-database-schema-design/columnstore.html
397+
[rowstore]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/concepts-of-physical-database-schema-design/rowstore.html
398+
[sparse]: https://docs.singlestore.com/managed-service/en/reference/sql-reference/data-definition-language-ddl/create-table.html#compression---sparse-and-sparse-behavior
399+
[shard key]: https://docs.singlestore.com/managed-service/en/developer-resources/porting-tables-to-singlestoredb-cloud/shard-keys.html
400+
[sort key]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/procedures-for-physical-database-schema-design/creating-a-columnstore-table.html
401+
[columnstore-tuning]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/procedures-for-physical-database-schema-design/configuring-the-columnstore-to-work-effectively.html
402+
[`storedAs`]: https://laravel.com/docs/9.x/migrations#column-modifiers
403+
[persisted computed column]: https://docs.singlestore.com/managed-service/en/create-a-database/physical-database-schema-design/procedures-for-physical-database-schema-design/using-persistent-computed-columns.html
404+
[singlestore-pem]: https://portal.singlestore.com/static/ca/singlestore_bundle.pem
405+
[Eloquent's attribute casting]: https://laravel.com/docs/9.x/eloquent-mutators#attribute-casting
406+
[create table]: https://docs.singlestore.com/managed-service/en/reference/sql-reference/data-definition-language-ddl/create-table.html

0 commit comments

Comments
 (0)