Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improvements to the LogEst command-line tool used to convert between ordinary numbers and the LogEst representation. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | row-size-est |
Files: | files | file ages | folders |
SHA1: |
5252aeb61988e511dcf8d527fa81e51a |
User & Date: | drh 2013-10-05 18:32:30.669 |
Context
2013-10-05
| ||
19:18 | Completely remove the iScanRatio field. The PRAGMA index_list(TABLE) command shows the estimated row size in the forth column. It also generates a row for the table with an index name of NULL. The query planner still does not take row size estimates into account - that is the next step. (check-in: 8b4aa0c7a2 user: drh tags: row-size-est) | |
18:32 | Improvements to the LogEst command-line tool used to convert between ordinary numbers and the LogEst representation. (check-in: 5252aeb619 user: drh tags: row-size-est) | |
18:16 | Begin an experimental refactoring to estimate the average number of bytes in table and index rows and to use that information in query planner. Begin by renaming WhereCost to LogEst and making that type and its conversion routines available outside of where.c. (check-in: 66c4a251d6 user: drh tags: row-size-est) | |
Changes
Changes to tool/logest.c.
︙ | ︙ | |||
70 71 72 73 74 75 76 | while( x<8 ){ y -= 10; x <<= 1; } }else{ while( x>255 ){ y += 40; x >>= 4; } while( x>15 ){ y += 10; x >>= 1; } } return a[x&7] + y - 10; } | | | | | > | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | while( x<8 ){ y -= 10; x <<= 1; } }else{ while( x>255 ){ y += 40; x >>= 4; } while( x>15 ){ y += 10; x >>= 1; } } return a[x&7] + y - 10; } static sqlite3_uint64 logEstToInt(LogEst x){ sqlite3_uint64 n; if( x<10 ) return 1; n = x%10; x /= 10; if( n>=5 ) n -= 2; else if( n>=1 ) n -= 1; if( x>=3 ) return (n+8)<<(x-3); return (n+8)>>(3-x); } static LogEst logEstFromDouble(double x){ sqlite3_uint64 a; LogEst e; assert( sizeof(x)==8 && sizeof(a)==8 ); if( x<=0.0 ) return -32768; if( x<1.0 ) return -logEstFromDouble(1/x); if( x<1024.0 ) return logEstFromInteger((sqlite3_uint64)(1024.0*x)) - 100; if( x<=2000000000.0 ) return logEstFromInteger((sqlite3_uint64)x); memcpy(&a, &x, 8); e = (a>>52) - 1022; return e*10; } int isFloat(const char *z){ while( z[0] ){ |
︙ | ︙ | |||
128 129 130 131 132 133 134 | a[n++] = logEstFromInteger(atoi(z)); } } for(i=n-1; i>=0; i--){ if( a[i]<0 ){ printf("%d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i])); }else{ | | > | 129 130 131 132 133 134 135 136 137 138 139 140 141 | a[n++] = logEstFromInteger(atoi(z)); } } for(i=n-1; i>=0; i--){ if( a[i]<0 ){ printf("%d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i])); }else{ sqlite3_uint64 x = logEstToInt(a[i]+100)*100/1024; printf("%d (%lld.%02lld)\n", a[i], x/100, x%100); } } return 0; } |