Repository navigation
contextdb: add joins, grouping, UNION, subqueries, graph patterns, ranked search and EXPLAIN to SELECT - #25
Merged
Merged
Conversation
…nked search and EXPLAIN to SELECT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The new engine under
v2/can now read across tables, walk a table of edges, rank a similarity search, and explain any statement without running it.What this adds
SELECTjoins tables (INNER,LEFTandCROSS JOIN). It groups withCOUNT,SUM,MIN,MAXandAVG,GROUP BYandHAVING. It also takesDISTINCT,WITH,UNIONandUNION ALL,INand one-value subqueries that do not read the outer row,LIKE,BETWEEN,ORDER BYany expression,LIMITandOFFSET, andROW_NUMBER() OVER (...).GRAPH_TABLE(edges MATCH (a)-[:TYPE]->{m,n}(b) COLUMNS (...))is a pattern over a table of edges. With a range, it reports each node once at the shallowest depth it is reached, whether the filter names no start, one start or several. A walk follows at most 10 edges.->and->>. JSON values compare by value and sort as Postgresjsonbsorts them. An index over a JSON field answers a condition on that field.ORDER BY ... USE RANK nameranks a similarity search by a formula the column declares.EXPLAINof anySELECT,INSERT,UPDATEorDELETEsays how the statement would be answered and changes nothing. It refuses a statement exactly as running it would refuse it for what is wrong in the statement itself.SHOWcolumns are now the words the industry uses.AUTO_INDEX_ATisINDEXING_THRESHOLDandCONSOLIDATIONisCOMPACTION. Theirdeclared_*andeffective_*columns follow, and so do three error names.pending_insertsispending_tuples,first_groupingisunindexedandoutside_groupingisunindexed_rows.REALare compared by exact value.What a narrowed reader is told, and what it is never told
A narrowed reader is a handle narrowed to some Contexts, some scope labels or a principal.
SELECTthat names one hidden row by its key is refused by the rule that hid it, so the reader can tell "not yours" from "not there". The refusal never carries a value of that row or a count.GRAPH_TABLEthat names one hidden start with=is refused the same way. A list of starts leaves the hidden one out, and NULL names no start.UPDATEorDELETEchanges no row the reader cannot see, and says so. A write that would put a row outside what the reader may write is refused.USE VECTOR INDEXED) by a narrowed reader is answered as an ordinary search (AUTO). It is never refused because of the state of the index.EXPLAINof a search prints only the declaration lines,filter_pathandrecovery. It prints nothing about routes, partitions,small_setor a refusal.EXPLAIN.rows_examined,distance_evaluations). Both depend on rows the reader may not see.The report line
The time is the six commands listed below, run one after another on the build machine described under "Speed", with the dependencies already compiled.
Checks run
check.yml):cargo test: 351 passed, none failed;ci.yml) also runs on this pull request, because the change touches files outsidev2/(docs/performance/andscripts/ci-local.py). It was run locally once: about 245 of its commands ran with no failure before its time limit stopped the run. It is proven by the hosted run.The false sentences, the two contradictions in the guide and the two findings that blocked a reader are fixed in this change.
Speed against the merged code
How the figures were taken:
v2/numbers.shruns, on the same stores loaded the same way. A search runs on one thread, reading under a 1 GiB memory limit.EXPLAINprints. The tests and pages changed after it do not enter the measuring programs.What each store holds and how it was loaded:
This change beside the merged code (the change before it), medians:
docs/performance/).Old engine against this one, statement by statement
1,583 statements of the 47 SQL scripts of the new engine's tests, run through the old engine's shell and through this one, each script on a fresh store for each engine, as they stood one line of engine code before this tree: 1,105 answer the same, 132 are the new form (a form the old engine refuses), 211 differ on purpose, each recorded as an intended difference from the old engine, 71 follow from those, 41 differ only in wording, 23 are old-engine defects this change corrects, 0 are defects of this change, and 0 differ without such a record.
Known limits
ORreads every row, as it did before this change.FROMis not supported; the statement does not parse. Name the subquery in aWITHand read that name instead.EXPLAINof a statement whoseWITHbody is a similarity search, such asEXPLAIN WITH x AS (<search>) SELECT * FROM x, is refused with thePlanError"explaining this statement is not supported in this version of the library", because a search inside aWITHprints no line of its own.rows_examined,distance_evaluations) count every row read, including rows a narrowed reader may not see, so a host serving such a reader should not pass them on.NOT, unary minus and subqueries; one deeper is aParseError.WITHname is handed back when it is no longer needed;