Tarantool CE/EE Documentation portal logo
Помощь
Обновлена 15 сентября 2026 г. в 08:55

index_object:count()

object index_object

index_object:count([key], [iterator])

Параметры:

  • index_object (index_object) — объект
  • key (scalar/table) — значения для сопоставления с ключом индекса
  • iterator — метод сравнения

Возвращает

количество совпадающих кортежей.

Тип возвращаемого значения

number

Ниже приведено несколько примеров использования count.

-- Insert test data --box.space.bands:insert { 1, 'Roxette', 1986 }box.space.bands:insert { 2, 'Scorpions', 1965 }box.space.bands:insert { 3, 'Ace of Base', 1987 }box.space.bands:insert { 4, 'The Beatles', 1960 }box.space.bands:insert { 5, 'Pink Floyd', 1965 }box.space.bands:insert { 6, 'The Rolling Stones', 1962 }box.space.bands:insert { 7, 'The Doors', 1965 }box.space.bands:insert { 8, 'Nirvana', 1987 }box.space.bands:insert { 9, 'Led Zeppelin', 1968 }box.space.bands:insert { 10, 'Queen', 1970 }-- Count the number of tuples that match the full key valuecount = box.space.bands.index.year:count(1965)--[[---- 3...--]]-- Count the number of tuples that match the partial key valuecount_partial = box.space.bands.index.year_band:count(1965)--[[---- 3...--]]