tarantool / tarantool/tarantool

SQL where optimizer doesn't use ONEPASS strategy at all

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

Nobody has claimed this yet.

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

Description

Here's stub from box/sql/where.c:

int
sqlite3WhereOkOnePass(WhereInfo * pWInfo, int *aiCur)
{
        memcpy(aiCur, pWInfo->aiCurOnePass, sizeof(int) * 2);
        /*  Tarantool workaround: one pass is not working right now, since deleting tuple
         *  invalidates pointing iterator (which is used to go through table).
         */
        if (pWInfo->eOnePass == ONEPASS_MULTI) {
                pWInfo->eOnePass = ONEPASS_OFF;
        }
...

This means that ONEPASS_MULTI is not used at all. Comment states
that it was disabled due to instability of Tarantool's iterators during
tuple delete. But look like this is not the case and this optimization
might be enabled. Immediate enabling leads to test fails, so need to
investigate.

If this mode is not possible to enable: remove comment and refactor
the function (and everything around in call-graph) to remove this stub.

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 in box/sql/where.c at sqlite3WhereOkOnePass and reproduce the test failures after enabling ONEPASS_MULTI. Trace the surrounding call graph to determine whether Tarantool iterator invalidation is still a problem. Done means either enabling the optimization with passing tests or removing the workaround and refactoring the related stub and call graph.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sql
Domain
databases, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.