summaryrefslogtreecommitdiff
path: root/heap/_check.c
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2004-09-08 02:07:53 +0400
committerunknown <sergefp@mysql.com>2004-09-08 02:07:53 +0400
commit99e1b8179eb88ad64e8cae7a6acd7822b94dda1f (patch)
tree5fb9bac74cdad46fce2efb3c783f9a02367489bd /heap/_check.c
parentc1f297058d39408e64902c852fb141e4c3dd64c1 (diff)
downloadmariadb-git-99e1b8179eb88ad64e8cae7a6acd7822b94dda1f.tar.gz
Fix for bug#5138: hash indexes on heap tables support statistics.
KEY::rec_per_key is updated every time 1/HEAP_STATS_UPDATE_THRESHOLD part of table records has been changed. heap/_check.c: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. heap/hp_clear.c: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. heap/hp_create.c: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. heap/hp_delete.c: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. heap/hp_hash.c: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. heap/hp_write.c: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. include/heap.h: Hash indexes on heap tables now support statistics - number of hash buckets. The value is updated on any insert/delete operation. mysql-test/r/heap.result: Fix for bug#5138: store/use statistics for hash indexes on heap tables mysql-test/r/heap_hash.result: Fix for bug#5138: store/use statistics for hash indexes on heap tables mysql-test/r/myisam.result: Fix for bug#5138: store/use statistics for hash indexes on heap tables mysql-test/t/heap_hash.test: Fix for bug#5138: store/use statistics for hash indexes on heap tables sql/structs.h: Added comments
Diffstat (limited to 'heap/_check.c')
-rw-r--r--heap/_check.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/heap/_check.c b/heap/_check.c
index 233cb8cb0c5..a745aee48bf 100644
--- a/heap/_check.c
+++ b/heap/_check.c
@@ -102,9 +102,11 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records,
int error;
uint i,found,max_links,seek,links;
uint rec_link; /* Only used with debugging */
+ uint hash_buckets_found;
HASH_INFO *hash_info;
error=0;
+ hash_buckets_found= 0;
for (i=found=max_links=seek=0 ; i < records ; i++)
{
hash_info=hp_find_hash(&keydef->block,i);
@@ -128,21 +130,32 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records,
found++;
}
if (links > max_links) max_links=links;
+ hash_buckets_found++;
}
}
if (found != records)
{
- DBUG_PRINT("error",("Found %ld of %ld records"));
+ DBUG_PRINT("error",("Found %ld of %ld records", found, records));
+ error=1;
+ }
+ if (keydef->hash_buckets != hash_buckets_found)
+ {
+ DBUG_PRINT("error",("Found %ld buckets, stats shows %ld buckets",
+ hash_buckets_found, keydef->hash_buckets));
error=1;
}
DBUG_PRINT("info",
- ("records: %ld seeks: %d max links: %d hitrate: %.2f",
+ ("records: %ld seeks: %d max links: %d hitrate: %.2f "
+ "buckets: %d",
records,seek,max_links,
- (float) seek / (float) (records ? records : 1)));
+ (float) seek / (float) (records ? records : 1),
+ hash_buckets_found));
if (print_status)
- printf("Key: %d records: %ld seeks: %d max links: %d hitrate: %.2f\n",
+ printf("Key: %d records: %ld seeks: %d max links: %d "
+ "hitrate: %.2f buckets: %d\n",
keynr, records, seek, max_links,
- (float) seek / (float) (records ? records : 1));
+ (float) seek / (float) (records ? records : 1),
+ hash_buckets_found);
return error;
}