tarantool / tarantool/tarantool
sql: optimization for full-key 'DELETE WHERE'
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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