OxL Справочник OxL
РусскийEnglish

warning scatter-gather

warning Стандарт: [IV.6]

Запрос к шардированной таблице без ключа шарда.

What it means#

The table has @shard(by: .f) (§12.8), but the query cannot be routed to one shard, so it runs on every shard and the results are merged (D-4388, D-6558): a from query whose where has no top-level x.f == value conjunct, all/count of the table, and find/deleteById when the shard key is not the primary key. Part IV.6: the shard key belongs in every query of a sharded table.

Example#

oxl✓ проверяется в CI
use std.orm { Db }

@table("orders") @shard(by: .userId)
data Order { @pk id: u64; userId: u64; total: i64 }

fn bigOrders(db: &Db) -> List<Order> db {
  from o in db.Order where o.total > 100      // <- scatter-gather
}
error
scatter-gather

How to fix#

oxl✓ проверяется в CI
use std.orm { Db }

@table("orders") @shard(by: .userId)
data Order { @pk id: u64; userId: u64; total: i64 }

fn bigOrders(db: &Db, user: u64) -> List<Order> db {
  from o in db.Order where o.userId == user && o.total > 100
}

Add the shard key to the query. If a cross-shard query is intended (a report, an admin page), keep it and lower the rule for the package with scatter-gather = "off" in [lint].

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства