From: drh <> Date: Mon, 24 Oct 2022 11:02:02 +0000 (+0000) Subject: Test cases for covering indexes on wide tables. X-Git-Tag: version-3.40.0~111^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcovering-index-enh;p=thirdparty%2Fsqlite.git Test cases for covering indexes on wide tables. FossilOrigin-Name: 64c3777eb356b15094a9e9fcc135499ba22f4d847fb117afa6ccf19986e33585 --- diff --git a/manifest b/manifest index 466a8bbb6a..dfeec2e4db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\swide-table\scovering\sindex\sdetection\smust\stake\sinto\saccount\saggregate\nqueries. -D 2022-10-23T20:09:13.523 +C Test\scases\sfor\scovering\sindexes\son\swide\stables. +D 2022-10-24T11:02:02.863 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1882,6 +1882,7 @@ F test/wherefault.test 6cf2a9c5712952d463d3f45ebee7f6caf400984df51a195d884cfb7eb F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3 F test/wherelimit.test afb46397c6d7e964e6e294ba3569864a0c570fe3807afc634236c2b752372f31 F test/wherelimit2.test 657a3f24aadee62d058c5091ea682dc4af4b95ffe32f137155be49799a58e721 +F test/widetab1.test c296a98e123762de79917350e45fa33fdf88577a2571eb3a64c8bf7e44ef74d1 F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2aeee74 F test/win32lock.test e0924eb8daac02bf80e9da88930747bd44dd9b230b7759fed927b1655b467c9c F test/win32longpath.test 4baffc3acb2e5188a5e3a895b2b543ed09e62f7c72d713c1feebf76222fe9976 @@ -2036,8 +2037,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f6d09c5a0df940dbaa716df70df28218985b83540b34c468989729a3421ef38c -R fd3c0067754c62608d43d72ec9e99f57 +P 9ac73f83c53b9fba10bb1b8bbfd1a8dc8a2dc4a655e811d5b96335dbf2b6fdac +R ff35d1f3645fbbb934cd300395b24fe9 U drh -Z 5bfa2fd79b68e79172127d7fb9b603ce +Z 474244313dc1a74df1056f4f86b5a3b2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 439d00ad72..790aa82555 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ac73f83c53b9fba10bb1b8bbfd1a8dc8a2dc4a655e811d5b96335dbf2b6fdac \ No newline at end of file +64c3777eb356b15094a9e9fcc135499ba22f4d847fb117afa6ccf19986e33585 \ No newline at end of file diff --git a/test/widetab1.test b/test/widetab1.test new file mode 100644 index 0000000000..39523ce882 --- /dev/null +++ b/test/widetab1.test @@ -0,0 +1,156 @@ +# 2022-10-24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements test cases for wide table (tables with more than +# 64 columns) and indexes that reference columns beyond the 63rd or 64th +# column. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix widetab1 + + +# In order to pick the better index in the following query, SQLite needs to +# be able to detect when an index that references later columns in a wide +# table is a covering index. +# +do_execsql_test 100 { + CREATE TABLE a( + a00, a01, a02, a03, a04, a05, a06, a07, a08, a09, + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, + a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, + a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, + a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, + a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, + pd, bn, vb, bc, cn, ie, qm); + CREATE INDEX a1 on a(pd, bn, vb, bc, cn); -- preferred index + CREATE INDEX a2 on a(pd, bc, ie, qm); -- suboptimal index + CREATE TABLE b(bg, bc, bn, iv, ln, mg); + CREATE INDEX b1 on b(bn, iv, bg); +} +do_eqp_test 110 { + SELECT dc, count(cn) + FROM (SELECT coalesce(b.bg, a.bc) as dc, cn + FROM a LEFT JOIN b + ON a.bn = b.bn + AND CASE WHEN a.vb IS NOT NULL THEN 1 ELSE 0 END = b.iv + WHERE pd BETWEEN 0 AND 10) + GROUP BY dc; +} { + QUERY PLAN + |--SEARCH a USING COVERING INDEX a1 (pd>? AND pd