Improve performance of sqlite3VdbeRecordCompare() by using an approximation

that might give false negatives and only running the more expensive exact 
subexpression if the approximation fails.

FossilOrigin-Name: 28979dcd16f53e0ddca8eed74b668834e2856f03
This commit is contained in:
drh 2013-08-05 15:32:09 +00:00
parent 407ceeb84d
commit af5b2af77d
3 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Add\sa\smissing\s'#include\s"tcl.h"'\sto\stest_rtree.c.
D 2013-08-05T12:31:41.375
C Improve\sperformance\sof\ssqlite3VdbeRecordCompare()\sby\susing\san\sapproximation\nthat\smight\sgive\sfalse\snegatives\sand\sonly\srunning\sthe\smore\sexpensive\sexact\s\nsubexpression\sif\sthe\sapproximation\sfails.
D 2013-08-05T15:32:09.754
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -281,7 +281,7 @@ F src/vdbe.c d6048a720c197db2f0e7d618e918bd2e2eff0322
F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4
F src/vdbeInt.h e9b7c6b165a31a4715c5aa97223d20d265515231
F src/vdbeapi.c 4d13580bd058b39623e8fcfc233b7df4b8191e8b
F src/vdbeaux.c 4389b3692969b4415fcfd00de36818a02f84df28
F src/vdbeaux.c 1a149d406d812b767d70c932dfc472d586d04c45
F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab
F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017
@ -1105,7 +1105,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 213020769f310aec1591d97756b53891d0b64005
R 0448e5af5431e1ece697200cba67ff6c
P 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4
R 338de61a71c3cd74b79152f7e9194e12
U drh
Z ddf1308995835ea195d91d2476e0f474
Z 467c61e8c494116a000cdb09272cb823

View File

@ -1 +1 @@
4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4
28979dcd16f53e0ddca8eed74b668834e2856f03

View File

@ -3023,7 +3023,18 @@ int sqlite3VdbeRecordCompare(
/* Read the serial types for the next element in each key. */
idx1 += getVarint32( aKey1+idx1, serial_type1 );
if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break;
/* Verify that there is enough key space remaining to avoid
** a buffer overread. The "d1+serial_type1+2" subexpression will
** always be greater than or equal to the amount of required key space.
** Use that approximation to avoid the more expensive call to
** sqlite3VdbeSerialTypeLen() in the common case.
*/
if( d1+serial_type1+2>(u32)nKey1
&& d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
){
break;
}
/* Extract the values to be compared.
*/