Fossil

Check-in [4389b36f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Performance improvement when browsing repositories with many files. This is an temporary fix - we can do much better.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 4389b36f4fa51f0ed1b4f8739a45b350736c4b8f
User & Date: drh 2010-10-25 00:33:43
Context
2010-10-25
00:55
Further performance enchancements for browsing. We could still do better, but the current seems fast enough. check-in: ee1cc2bf user: drh tags: experimental
00:33
Performance improvement when browsing repositories with many files. This is an temporary fix - we can do much better. check-in: 4389b36f user: drh tags: experimental
2010-10-23
20:24
Create or delete the manifest and manifest.uuid files when turning the manifest setting on and off. check-in: 8175b579 user: drh tags: experimental
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/browse.c.

97
98
99
100
101
102
103

104
105
106
107
108
109
110
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193



194
195

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
** Query parameters:
**
**    name=PATH        Directory to display.  Required.
**    ci=LABEL         Show only files in this check-in.  Optional.
*/
void page_dir(void){
  const char *zD = P("name");

  int mxLen;
  int nCol, nRow;
  int cnt, i;
  char *zPrefix;
  Stmt q;
  const char *zCI = P("ci");
  int rid = 0;
................................................................................
  **
  ** Subdirectory names begin with "/".  This causes them to sort
  ** first and it also gives us an easy way to distinguish files
  ** from directories in the loop that follows.
  */
  db_multi_exec(
     "CREATE TEMP TABLE localfiles(x UNIQUE NOT NULL, u);"
     "CREATE TEMP TABLE allfiles(x UNIQUE NOT NULL, u);"
  );
  if( zCI ){
    Stmt ins;
    ManifestFile *pFile;

    db_prepare(&ins, "INSERT INTO allfiles VALUES(:x, :u)");



    manifest_file_rewind(pM);
    while( (pFile = manifest_file_next(pM,0))!=0 ){

      db_bind_text(&ins, ":x", pFile->zName);
      db_bind_text(&ins, ":u", pFile->zUuid);
      db_step(&ins);
      db_reset(&ins);
    }
    db_finalize(&ins);
  }else{
    db_multi_exec(
      "INSERT INTO allfiles SELECT name, NULL FROM filename"
    );
  }
  if( zD ){
    db_multi_exec(
       "INSERT OR IGNORE INTO localfiles "
       "  SELECT pathelement(x,%d), u FROM allfiles"
       "   WHERE x GLOB '%q/*'",
       strlen(zD)+1, zD
    );
  }else{
    db_multi_exec(
       "INSERT OR IGNORE INTO localfiles "
       "  SELECT pathelement(x,0), u FROM allfiles"
    );
  }

  /* Generate a multi-column table listing the contents of zD[]
  ** directory.
  */
  mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");







>







 







<





|
>
>
>


>






<
<
<
<
<
|

|
|
|
|



|
|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205





206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
** Query parameters:
**
**    name=PATH        Directory to display.  Required.
**    ci=LABEL         Show only files in this check-in.  Optional.
*/
void page_dir(void){
  const char *zD = P("name");
  int nD = zD ? strlen(zD) : 0;
  int mxLen;
  int nCol, nRow;
  int cnt, i;
  char *zPrefix;
  Stmt q;
  const char *zCI = P("ci");
  int rid = 0;
................................................................................
  **
  ** Subdirectory names begin with "/".  This causes them to sort
  ** first and it also gives us an easy way to distinguish files
  ** from directories in the loop that follows.
  */
  db_multi_exec(
     "CREATE TEMP TABLE localfiles(x UNIQUE NOT NULL, u);"

  );
  if( zCI ){
    Stmt ins;
    ManifestFile *pFile;

    db_prepare(&ins,
       "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,%d), :u)",
       nD ? nD+1 : 0
    );
    manifest_file_rewind(pM);
    while( (pFile = manifest_file_next(pM,0))!=0 ){
      if( nD>0 && memcmp(pFile->zName, zD, nD)!=0 ) continue;
      db_bind_text(&ins, ":x", pFile->zName);
      db_bind_text(&ins, ":u", pFile->zUuid);
      db_step(&ins);
      db_reset(&ins);
    }
    db_finalize(&ins);





  }else if( zD ){
    db_multi_exec(
      "INSERT OR IGNORE INTO localfiles"
      " SELECT pathelement(name,%d), NULL FROM filename"
      "  WHERE name GLOB '%q/*'",
      nD+1, zD
    );
  }else{
    db_multi_exec(
      "INSERT OR IGNORE INTO localfiles"
      " SELECT pathelement(name,0), NULL FROM filename"
    );
  }

  /* Generate a multi-column table listing the contents of zD[]
  ** directory.
  */
  mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");