Skip to content

Commit 2bddc22

Browse files
committed
remove from tail of filelist on modern postgres
Modern postgres actually uses array as List implementation. Therefore, removing element from head is quite expensive.
1 parent 78baca7 commit 2bddc22

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎ptrack.c

+9
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,21 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
402402
if (list_length(ctx->filelist) == 0)
403403
return -1;
404404

405+
#ifdef foreach_current_index
406+
/* Get first file from the head */
407+
cell = list_tail(ctx->filelist);
408+
pfl = (PtrackFileList_i *) lfirst(cell);
409+
410+
/* Remove this file from the list */
411+
ctx->filelist = list_delete_last(ctx->filelist);
412+
#else
405413
/* Get first file from the head */
406414
cell = list_head(ctx->filelist);
407415
pfl = (PtrackFileList_i *) lfirst(cell);
408416

409417
/* Remove this file from the list */
410418
ctx->filelist = list_delete_first(ctx->filelist);
419+
#endif
411420

412421
if (pfl->segno > 0)
413422
{

0 commit comments

Comments
 (0)