Daniel Shahaf wrote on Fri, Feb 11, 2022 at 17:39:42 +0000:
> Julian Foad wrote on Fri, Feb 11, 2022 at 14:48:28 +0000:
> > On 'pristines-on-demand-on-mwf':
> ⋮
> > I could do with some help on a SQL test FAIL, when testing against the
> > older WC format, in wc-queries-test 3: test_query_expectations(). It
> > looks like this:
> > 
> > $ (SRC_DIR=$PWD; cd obj-dir/subversion/tests/libsvn_wc &&
> > ./wc-queries-test --cleanup
> > --config-file=$SRC_DIR/subversion/tests/tests.conf
> > --srcdir=$SRC_DIR/subversion/tests/libsvn_wc --wc-format-version=1.14 3
> > | sed "s#$SRC_DIR/##")
> > 
> > subversion/tests/libsvn_wc/wc-queries-test.c:815: 
> > (apr_err=SVN_ERR_TEST_FAILED)
> > svn_tests: E200006: STMT_SELECT_UNREFERENCED_PRISTINES: Uses pristine with 
> > only 0 index component: ((null))
> > SELECT checksum FROM pristine WHERE refcount = 0 
> > subversion/tests/libsvn_wc/wc-queries-test.c:868: 
> > (apr_err=SVN_ERR_COMPOSED_ERROR)
> > svn_tests: E200042: Additional errors:
> > subversion/tests/libsvn_wc/wc-queries-test.c:868: 
> > (apr_err=SVN_ERR_SQLITE_CONSTRAINT)
> > svn_tests: E200035: |SCAN TABLE pristine
> > FAIL:  wc-queries-test 3: test query expectations
> > 
> > The failure is within:
> >     if (item->search
> >         && ((item->expression_vars < 2 && is_node_table(item->table)) 
> >             || (item->expression_vars < 1))
> >         && !is_result_table(item->table))
> > 
> > I have taken a look and cannot work out what it means.
> 
> In short, it's checking whether SQLite is using sufficiently many index
> columns.  STMT_SELECT_UNREFERENCED_PRISTINES does a table scan without
> using an index, meaning that query does O(N) work where N is the number
> of rows in the table.
> 
> To confirm that, does the test pass if you do «CREATE INDEX foo ON
> pristine(refcount)» when creating the SQLite database the test runs on?
> 
> I haven't looked to see whether that's the right fix.  That would depend
> on whether STMT_SELECT_UNREFERENCED_PRISTINES needs to be performant,
> and if it does, on what kind of index would best serve it without
> affecting other queries (e.g., INSERTs and DELETEs to that table).
> 
> > Maybe the statement needs to be made to match the exception clause
> > "in_list(primary_key_statements, i)", but that's just a semi-educated guess.
> 
> The statements in that list both have «LIMIT 1» on them.  That'd be why
> they're exempted from the "all queries must use an index" check.
> 
> >
> 
> Excuse brevity.

Looked a bit more.  The branch removes STMT_SELECT_UNREFERENCED_PRISTINES from 
slow_statements[]
unconditionally and then creates I_PRISTINE_UNREFERENCED only for f32
wc's.  So, just add that statement to that array for f31 wc's.

Daniel

Reply via email to