Streaming table reads

To read an entire table snapshot, use the readtable subcommand. Data is transferred as a stream, which enables you to read any size table.

Read data:

  1. ydb table readtable episodes \
  2. --ordered \
  3. --limit 5 \
  4. --columns series_id,season_id,episode_id,title

Streaming table reads - 图1

Where:

  • --ordered: Order read entries by key.
  • --limit: Limit the number of entries to read.
  • --columns: Columns whose values should be read (all by default) in CSV format.

Result:

  1. ┌───────────┬───────────┬────────────┬───────────────────────────────┐
  2. | series_id | season_id | episode_id | title |
  3. ├───────────┼───────────┼────────────┼───────────────────────────────┤
  4. | 1 | 1 | 1 | "Yesterday's Jam" |
  5. ├───────────┼───────────┼────────────┼───────────────────────────────┤
  6. | 1 | 1 | 2 | "Calamity Jen" |
  7. ├───────────┼───────────┼────────────┼───────────────────────────────┤
  8. | 1 | 1 | 3 | "Fifty-Fifty" |
  9. ├───────────┼───────────┼────────────┼───────────────────────────────┤
  10. | 1 | 1 | 4 | "The Red Door" |
  11. ├───────────┼───────────┼────────────┼───────────────────────────────┤
  12. | 1 | 1 | 5 | "The Haunting of Bill Crouse" |
  13. └───────────┴───────────┴────────────┴───────────────────────────────┘

Streaming table reads - 图2

To only get the number of read entries, use the --count-only parameter:

  1. ydb table readtable episodes \
  2. --columns series_id \
  3. --count-only

Streaming table reads - 图3

Result:

  1. 70

Streaming table reads - 图4