Commit c545b026 authored by unknown's avatar unknown

Fix for Bug #1952

"SHOW TABLE STATUS very slow w/large number of tables"
Replaced old algorithm which were used in my_dir() and stored
all information about directory entries in one chunk of memory
with new one which stores file names and MY_STAT structures in
separate memroot, so now we don't need to copy this data during
reallocation of dir_entry array.


include/my_dir.h:
  Changed mystat member of FILEINFO structure to pointer since 
  this prevents unneeded memory allocation and initialization.
  Added comment about new hidden members of MY_DIR structure.
mysys/my_lib.c:
  Replaced old algorithm in my_dir() which stored all information
  about directory entries in one chunk of memory with new one 
  which stores file names and MY_STAT structures in separate
  memroot. Now we don't copy this data during reallocation of 
  array with FILEINFO structures.
  Also tuned sizes of memory chunks during first-other
  reallocations (we suppose that we either have < 100 files 
  in the directory or > 1000 of them).
sql/sql_show.cc:
  Updated only place in code where mystat member
  of FILEINFO structure is used.
parent 22c12eae
......@@ -74,14 +74,21 @@ typedef struct my_stat
#endif /* USE_MY_STAT_STRUCT */
typedef struct fileinfo /* Struct returned from my_dir & my_stat */
/* Struct describing one file returned from my_dir */
typedef struct fileinfo
{
char *name;
MY_STAT mystat;
MY_STAT *mystat;
} FILEINFO;
typedef struct st_my_dir /* Struct returned from my_dir */
{
/*
These members are just copies of parts of DYNAMIC_ARRAY structure,
which is allocated right after the end of MY_DIR structure (MEM_ROOT
for storing names is also resides there). We've left them here because
we don't want to change code that uses my_dir.
*/
struct fileinfo *dir_entry;
uint number_off_files;
} MY_DIR;
......
This diff is collapsed.
......@@ -213,7 +213,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
else
#endif
{
if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat.st_mode) ||
if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat->st_mode) ||
(wild && wild_compare(file->name,wild)))
continue;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment