tarantool / tarantool/tarantool

sql: optimization for full-key 'DELETE WHERE'

Open
#3,267 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

optimization performance sql
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Currently, OP_Delete (i.e. VDBE opcode which implements delete logic) can operate only on cursors: firstly it is required to open cursor, then to position this cursor to record to be deleted (by fetching tuple into cursor), to handle all checks in 'WHERE' clause and finally fetch key from tuple and delete record. However, if all key fields are specified in 'WHERE' clause and there are no other conditions, we are capable of deleting record without cursor positioning.
For instance:

\set language sql
CREATE TABLE t1(id PRIMARY KEY, a, b, c);
INSERT INTO t1 VALUES (1, 2, 3, 4), (2, 0, 2, 3), (3, 1, 0, 3);
DELETE FROM t1 WHERE id = 1 or id = 3; 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the OP_Delete VDBE opcode and the SQL DELETE path described in the issue. Use the provided CREATE TABLE, INSERT, and full-key DELETE example to compare behavior, and consider the work complete when qualifying deletes can avoid cursor positioning without changing the resulting rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.