From b589949bf4403d1a5d45c037daa6726720f41b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 7 Jan 2016 17:30:33 +0100 Subject: [PATCH] README.md --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b2805806a..01deab593 100644 --- a/README.md +++ b/README.md @@ -333,9 +333,7 @@ See [Values](#values) for more information on supported arguments types (Bool, I Both `fetch` and `fetchAll` let you iterate the full list of fetched rows. The differences are: - `fetchAll` performs a single request, and returns an array that can be iterated on any thread. It can take a lot of memory. -- `fetch` returns a sequence that performs a new request each time it is iterated. It must be consumed in the database queue (you'll get a fatal error if you do otherwise). - -Row sequences also grant the fastest access to the database. This performance advantage comes with extra precautions: +- `fetch` returns a sequence that performs a new request each time it is iterated. It is memory efficient, but must be consumed in the database queue (you'll get a fatal error if you do otherwise). > :point_up: **Don't turn a row sequence into an array** with `Array(rowSequence)` or `rowSequence.filter { ... }`: you would not get the distinct rows you expect. To get an array, use `Row.fetchAll(...)`. > @@ -531,7 +529,7 @@ dbQueue.inDatabase { db in Both `fetch` and `fetchAll` let you iterate the full list of fetched values. The differences are: - `fetchAll` performs a single request, and returns an array that can be iterated on any thread. It can take a lot of memory. -- `fetch` returns a sequence that performs a new request each time it is iterated. It must be consumed in the database queue (you'll get a fatal error if you do otherwise). +- `fetch` returns a sequence that performs a new request each time it is iterated. It is memory efficient, but must be consumed in the database queue (you'll get a fatal error if you do otherwise). `fetchOne` returns an optional value which is nil in two cases: either the SELECT statement yielded no row, or one row with a NULL value. @@ -1375,7 +1373,7 @@ See [Column Values](#column-values) for more information about the `row.value()` Both `fetch` and `fetchAll` let you iterate the full list of fetched objects. The differences are: - `fetchAll` performs a single request, and returns an array that can be iterated on any thread. It can take a lot of memory. -- `fetch` returns a sequence that performs a new request each time it is iterated. It must be consumed in the database queue (you'll get a fatal error if you do otherwise). +- `fetch` returns a sequence that performs a new request each time it is iterated. It is memory efficient, but must be consumed in the database queue (you'll get a fatal error if you do otherwise). > :point_up: **Note**: For performance reasons, the same row argument to `fromRow(:)` is reused during the iteration of a fetch query. If you want to keep the row for later use, make sure to store a copy: `result.row = row.copy()`. @@ -1430,7 +1428,7 @@ Person.fetchOne(db, key: ...) // Person? Both `fetch` and `fetchAll` let you iterate the full list of fetched objects. The differences are: - `fetchAll` performs a single request, and returns an array that can be iterated on any thread. It can take a lot of memory. -- `fetch` returns a sequence that performs a new request each time it is iterated. It must be consumed in the database queue (you'll get a fatal error if you do otherwise). +- `fetch` returns a sequence that performs a new request each time it is iterated. It is memory efficient, but must be consumed in the database queue (you'll get a fatal error if you do otherwise). The order of sequences and arrays returned by the key-based methods is undefined. To specify the order of returned elements, use a raw SQL query. @@ -1935,7 +1933,7 @@ dbQueue.inDatabase { db in Both `fetch` and `fetchAll` let you iterate the full list of fetched records. The differences are: - `fetchAll` performs a single request, and returns an array that can be iterated on any thread. It can take a lot of memory. -- `fetch` returns a sequence that performs a new request each time it is iterated. It must be consumed in the database queue (you'll get a fatal error if you do otherwise). +- `fetch` returns a sequence that performs a new request each time it is iterated. It is memory efficient, but must be consumed in the database queue (you'll get a fatal error if you do otherwise). For example: