Try   HackMD

.tarantool_history

1+1
\set output lua
"asd"
\set output yaml
1,2,3
"str1","str2"
{ 1,2,3 }
{ key="value", k = "val" }
help()
tutorial()
5.1, "Olá", "Lua"
tutorial("next")
box.cfg{}
box.tuple.new({ 1,2,3 })
box.tuple.new({ key = "val" })
box.tuple.new({ 1,2,3, "qwe", 1, "zxc" })
box.tuple.new({ 1,2,3, "qwe", 1, "zxc", { 1,2,3, {key = { other = { k ="val" }}} } })
box.tuple.new({ 1,2,3, "qwe", 1, "zxc", { 1,2,3, {key = { other = { k ="val" }}} } })[ 7 ]
box.tuple.new({ 1,2,3, "qwe", 1, "zxc", { 1,2,3, {key = { other = { k ="val" }}} } })[ 7 ][4]
box.tuple.new({ 1,2,3, "qwe", 1, "zxc", { 1,2,3, {key = { other = { k ="val" }}} } })[ 7 ][4].key
box.tuple.new({ 1,2,3, "qwe", 1, "zxc", { 1,2,3, {key = { other = { k ="val" }}} } })[ 7 ][4].key.other
box.schema.create_space('test')
box.schema.create_space('other')
box.space
box.space.test:insert( box.tuple.new({1,2,3}) )
box.space.test:create_index('pri')
box.space.test.index.pri:drop()
box.space.test:create_index('pri', { parts = { 1, 'str' } })
box.space.test:insert( box.tuple.new({1,2,3}) )
box.space.test:insert( box.tuple.new({"key1",2,3}) )
box.space.test:insert( box.tuple.new({"key2"}) )
box.space.test:insert( box.tuple.new({"key2", "str"}) )
box.space.test:insert( box.tuple.new({"key3", "str"}) )

box.space.test:insert( {"key4", { key = "value" } } )
box.space.test:create_index('sec', { parts = { 2, 'str' }  })
box.space.test:create_index('sec', { parts = { 2, 'num' }  })
box.space.test:truncate()
box.space.test:insert( {"key1", 1, "str" )
box.space.test:insert( {"key1", 1, "str" } )
box.space.test:insert( {"key2", 2, "str2" } )
box.space.test:insert( {"key3", 3, "str3" } )
box.space.test:create_index('sec', { parts = { 2, 'num' }  })
box.space.test:create_index('other', { parts = { 3, 'str', 1, 'str' }  })
box.space.index
box.space.test.index
box.space.test.index.pri:select()
box.space.test.index.sec:select()
box.space.test:insert( {"key4", 0, "otther" } )
box.space.test.index.sec:select()
box.space.test.index.other:select()
box.space.test:insert( {"key5", 0, "otther" } )
box.space.test:insert( {"key5", 8, "otther" } )
box.space.test:insert( {"key6", 7, "otther" } )
box.space.test.index.pri:select()
box.space.test.index.sec:select()
box.space.test.index.other:select()
box.space.test.index.other:select({ 'other' })
box.space.test.index.other:select({ 'otther' })
box.space.test.index.other:select({ 'otther' }, { iterator = 'GT' })
box.space.test.index.other:pairs({ 'otther' }, { iterator = 'GT' })
for _, tuple in box.space.test.index.other:pairs({ 'otther' }, { iterator = 'GT' }) do print(tuple) end
for _, tuple in box.space.test.index.other:pairs({ 'otther' }, { iterator = 'GT' }) do print(tuple) break end
for _, tuple in box.space.test.index.other:pairs({ 'otther' }, { iterator = 'EQ' }) do print(tuple) break end
for _, tuple in box.space.test.index.other:pairs({ 'otther' }, { iterator = 'EQ' }) do print(tuple) end
for _, tuple in box.space.test.index.other:pairs({ 'otther', 'key5' }, { iterator = 'EQ' }) do print(tuple) end
for _, tuple in box.space.test.index.other:pairs({ 'otther', 'key9' }, { iterator = 'EQ' }) do print(tuple) end
box.space.other:create_index('primary')
for i = 1,100 do box.space.other:insert{ i, "str"..i } end
box.space.other:select{}
box.space.other:pairs({5}, { iterator = 'GT' })
box.space.other:select({5}, { iterator = 'GT' })
for _,t in box.space.other:pairs({5}, { iterator = 'GT' }) do print(t) if t[1] > 10 then break end
end
for _,t in box.space.other:pairs({5}, { iterator = 'GT' }) do if t[1] > 10 then break print(t) end end
for _,t in box.space.other:pairs({5}, { iterator = 'GT' }) do if t[1] > 10 then break end print(t) end
for _,t in box.space.other:pairs({5}, { iterator = 'GE' }) do if t[1] > 10 then break end print(t) end
for _,t in box.space.other:pairs({5}, { iterator = 'LE' }) do if t[1] > 10 then break end print(t) end
for _,t in box.space.other:pairs({ 20 }, { iterator = 'LE' }) do if t[1] > 10 then break end print(t) end
for _,t in box.space.other:pairs({ 20 }, { iterator = 'LE' }) do if t[1] < 10 then break end print(t) end
box.space.other:pairs({}):take(5):totable()
box.space.other:pairs({ 6 }):take(5):totable()
box.space.other:pairs({ 6 }, { iterator = 'GE' }):take(5):totable()
box.space.other:pairs({ 6 }, { iterator = 'GT' }):take(5):totable()
box.space.other:pairs({ 6 }, { iterator = 'GT' }):take_while(function(t) return t[1] < 10 end):totable()
for k,v in box.space.other:pairs({ 6 }, { iterator = 'GT' }):take_while(function(t) return t[1] < 10 end) do print(v) end
box.space.other:create_index('sec', { parts = { 2, 'str', 1, 'num' } } )
box.space.other.index.sec
box
box.space
box.space.test
box.space.test:select()
box.space.test.select( box.space.test )
box.space.test:select( )
alksjdlsajdlkasdlj
{ 1, lasjdlasjdlkasjdlk }
{ 1 }
{ 1, nil, 3, "str" }
print( "qwewqe" )
require'log'.info( "qweqwe" )
box.cfg{ listen = 3301 }
box.schema.user.grant('guest','super')
box.space.other.index.sec:pairs({ 6 }, { iterator = 'GT' } ):take(3):totable()
box.space.other.index.sec:pairs({ 'str6' }, { iterator = 'GT' } ):take(3):totable()
box.space.other.index.sec:select({ 'str60' })
local val = 'str60' box.space.other.index.sec:select({ val })
local val = 'str60' return box.space.other.index.sec:select({ val })
local val return box.space.other.index.sec:select({ val })
local val return box.space.other.index.sec:select({})
box.space.other:pairs():nth(1)
box.space.other:pairs():nth(2)
box.space.other:pairs():nth(3)
box.space.other:pairs():take(10):totable()
for i = 11,1e5 do box.space.other:insert{ i, "str"..i } end
for i = 101,1e5 do box.space.other:insert{ i, "str"..i } end
local t = box.space.other:select() return t[100000]
box.space.other.index.sec
box.space.other.index.sec:select({'str123'})
box.space.other.index.sec:select({'str123',123})
box.space.other.index.sec:pairs({'str123'}, { iterator ='GE' }):take(5):totable()
\set language sql
select * from other limit 10;
select * from "other" limit 10;
\set language lua
box.space.other:format( { {name = "id", type = "int"}, { name ="value", type = "str" } } )
box.space.other:format( { {name = "id", type = "integer"}, { name ="value", type = "str" } } )
box.space.other:format( { {name = "id"}, { name ="value", type = "str" } } )
box.space.other:format( { {name = "id" }, { name ="value" } } )
box.space.other:format( {} )
box.space.other:format( )
box.space.other:format( { {name = "id" }, { name ="value" } } )
box.space.other:format( )
box.space.other:format( { {name = "id", type = "integer" }, { name ="value", type = "str" } } )
\set language sql
select * from "other" limit 10;
select * from "other" order by id desc limit 10;
select * from "other" order by "id" desc limit 10;
select * from "other" where id > 50000 order by "id" desc limit 10;
select * from "other" where "id" > 50000 order by "id" desc limit 10;
select * from "other" where "id" > 50000 limit 10;
select * from "other" where "id" > 50000  limit 10;
select * from "other" where "id" > 50000 order by "id" desc limit 10;
select * from "other" where "id" < 50000 order by "id" desc, "value" asc limit 10;
select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10;
select * from "other" where "id" > 50000 order by "id" desc, "value" desc limit 10;
select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10;
explain select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10;
create table test(id int primary key)
drop table test
create table test(id int primary key, value str)
create table test(id int primary key, value string)
insert into test values(1,"asjkhdaskd"),(2,"zxczxc")
insert into test values(1,'asjkhdaskd'),(2,'zxczxc')
\set language lua
box.space
box.space.TEST:select()
box.space.TEST:format()
local v = "string" return v
local v = 'string' return v
local v = [[string]] return v
local v = [[sdkdlkfsj " ' string]] return v
box.execute([[ select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10; ]])
local res = box.execute([[ select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10; ]]) return res.metadata
local res = box.execute([[ select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10; ]]) return res.rows[10]
local res = box.execute([[ select * from "other" where "id" < 50000 order by "id" desc, "value" desc limit 10; ]]) return res.rows
local res = box.execute([[ select * from "other" where "id" < ? order by "id" desc limit 10; ]], { 500 }) return res.rows
help()
\set language lua
box.schema.create_space('joined')
for i = 1,1e5 do box.space.joined:insert{ i, "othe value"..i } end
box.space.joined:create_index('pri')
for i = 1,1e5 do box.space.joined:insert{ i, "othe value"..i } end
box.space.other:pairs({50000},{iterator = 'GT'}):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) print(v)  end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) print(v) return v end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } return v,j end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } return { v,j } end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } v = v:unpack() if j then table.insert(v,#v,j:totable()) end end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } v = v:unpack() if j then table.insert(v,j:totable()) end end):take(10):totable()
box.tuple.new( {1,2,3} ):unpack()
box.tuple.new( {1,2,3} ):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } v = v:totable() if j then table.insert(v,#v,j:totable()) end end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } v = v:totable() if j then table.insert(v,#v,j:totable()) end return v end):take(10):totable()
box.space.other:pairs({50000},{iterator = 'GT'}):map(function(v) local j = box.space.joined:get{ v[1] } v = v:totable() if j then table.insert(v,#v+1,j:totable()) end return v end):take(10):totable()
box.space.joined:format({{name="id",type="number"},{name="value",type="string"}})
\set language sql
select * from "other" inner join "joined" on "other".id == "joined"."id" limit 1
select * from "other" inner join "joined" on "other"."id" == "joined"."id" limit 1;
select * from "other" inner join "joined" on "other"."id" == "joined"."id" limit 10;
select * from "other" inner join "joined" using ("id") limit 10;
select * from "other" inner join "joined" on "other"."id" = "joined"."id" limit 10;
select * from  "other","joined" where "other"."id" = "joined"."id" limit 10;
\set language lua
for i = 1e5+1,1e6 do box.space.joined:insert{ i, "other value "..i } end
box.space.joined:select() return 1
clock = requre 'clock'
clock = require 'clock'
clock.time()
local s = clock.time() box.space.joined:select() return clock.time() - s
box.space.joined:len()
local s = clock.time() box.execute[[ select * from joined; ]] return clock.time() - s
local s = clock.time() local t = box.execute[[ select * from joined; ]] return clock.time() - s
local s = clock.time() local t = box.execute[[ select * from joined; ]] return clock.time() - s, #t
local s = clock.time() local t,e = box.execute[[ select * from joined; ]] return clock.time() - s,t,e
local s = clock.time() local t,e = box.execute[[ select * from "joined"; ]] return clock.time() - s,t and #t,e
local s = clock.time() local t,e = box.execute[[ select * from "joined"; ]] return clock.time() - s,t and #t.rows,e
local s = clock.time() local t = box.space.joined:select() return clock.time() - s, t and #t
local s = clock.proc() local t,e = box.execute[[ select * from "joined"; ]] return clock.proc() - s,t and #t.rows,e
local s = clock.proc() local t = box.space.joined:select() return clock.proc() - s, t and #t
clock.proc64()
clock.time64()
clock.time64(), clock.time64()
clock.time64()-clock.time64()
-clock.time64()+clock.time64()